VALUE rb_cParameter, rb_cParEnumerable, rb_cParameterRef;
VALUE gMolbyBacktrace;
+VALUE gMolbyErrorHistory;
VALUE gScriptMenuCommands;
VALUE gScriptMenuEnablers;
VALUE sval, fnval, lnval, retval;
VALUE binding;
- /* Clear the error information */
- rb_set_errinfo(Qnil);
+ /* Clear the error information (store in the history array if necessary) */
+ sval = rb_errinfo();
+ if (sval != Qnil) {
+ rb_eval_string("$error_history.push([$!.to_s, $!.backtrace])");
+ rb_set_errinfo(Qnil);
+ }
if (s_ruby_top_self == Qfalse) {
s_ruby_top_self = rb_eval_string("eval(\"self\",TOPLEVEL_BINDING)");
/* Capture exit and return the status value */
retval = (RubyValue)rb_funcall(last_exception, rb_intern("status"), 0);
*status = 0;
+ rb_set_errinfo(Qnil);
}
}
s_SetInterruptFlag(Qnil, save_interrupt_flag);
#endif
- /* Global variable to hold backtrace */
+ /* Global variable to hold error information */
rb_define_variable("$backtrace", &gMolbyBacktrace);
-
+ rb_define_variable("$error_history", &gMolbyErrorHistory);
+ gMolbyErrorHistory = rb_ary_new();
+
/* Global variables for script menus */
rb_define_variable("$script_menu_commands", &gScriptMenuCommands);
rb_define_variable("$script_menu_enablers", &gScriptMenuEnablers);