From: ts Date: 2002-01-13T19:53:31+09:00 Subject: Re: syntax checking and error message >>>>> "S" == Shan-leung Maverick WOO writes: S> From eval.c, it seems that I should first use rb_compile_string and then S> check ruby_nerrs. But then I don't know how to retrieve a good error S> message. Currently I reset ruby_nerrs and then set use S> rb_eval_string_protect, but that means all the side-effects before the S> error will be committed and that's not very desirable. Is there a way to S> do it properly? Well, I don't know what you are trying to do, but ruby first compile the string and if there is no compile error it will execute the nodes. This mean that if you use rb_eval_string_protect() you'll not have side-effects if it exist a compile error. Now if you also want to test that the string can be executed without any error but don't want side-effect it's perhaps best to use rb_eval_string_wrap() because the nodes will be executed in an anonymous module. With rb_eval_string_{protect,wrap} you don't need to use ruby_nerrs. If you have an error you can retrieve the message with something like VALUE err = rb_inspect(rb_gv_get("$!")); Guy Decoux