From: ts Date: 2001-09-24T19:38:52+09:00 Subject: [ruby-talk:21626] Re: C++ / Ruby questions again >>>>> "B" == =?ISO-8859-1?Q?Bernhard Gl=FCck?= writes: B> Now my only help would be a method or other way like rb_respond_to to B> check wether a method needs a parameter and if yes how many.. so that B> i only call it when it has the appropriate paramter count.. Is there a B> way to do this ? #arity must give what you want with a Proc, or a Method object B> Second, i askes about how to catch all ruby exceptions.. I think i did B> not state clearly what i wanted, i already used rb_eval_string_protect B> for code evaluation.. so no crashes happened.. but If e.g a ruby B> program throws a string exception i want to present that string to the B> user of my program... so is there a way to intercept exceptions check B> if they have a presentable data type and display it ? without B> interupting program flow ? Maybe with a callback function ? Well, rb_eval_string_protect() return in the parameter state the error code. This mean that you can write something like this (not tested) state = 0; result = rb_eval_string_protect(string, &state); if (state) { VALUE error = rb_inspect(rb_gv_get("$!")); /* do what you want with error, it's a String VALUE */ } Guy Decoux