show exception info
This commit is contained in:
parent
9ac87315fa
commit
ca12750749
6
main.c
6
main.c
@ -9,7 +9,10 @@ static VALUE eval(const char * string)
|
||||
VALUE v = rb_eval_string_protect(string, &state);
|
||||
if (state != 0)
|
||||
{
|
||||
fprintf(stderr, "rb_eval_string_protect() returned state %d!\n", state);
|
||||
// fprintf(stderr, "rb_eval_string_protect() returned state %d!\n", state);
|
||||
VALUE e = rb_errinfo();
|
||||
VALUE s = rb_funcall(e, rb_intern("message"), 0);
|
||||
printf("%s\n", StringValueCStr(s));
|
||||
rb_set_errinfo(Qnil);
|
||||
}
|
||||
return v;
|
||||
@ -27,6 +30,7 @@ int main(int argc, char *argv[])
|
||||
ruby_init_loadpath();
|
||||
VALUE v = eval("3 + 8");
|
||||
printf("v: %d\n", FIX2INT(v));
|
||||
eval("yoda");
|
||||
eval("File.open('out.txt', 'w') {|fh| fh.puts 'hello!'}");
|
||||
eval("puts 'Hello, World!'");
|
||||
ruby_finalize();
|
||||
|
Loading…
x
Reference in New Issue
Block a user