From: Ferenc Engard Date: 2003-10-09T08:50:56+09:00 Subject: exception backtrace for ruby/tk programs Hello, I suffered with really hard debugging sessions when an unexpected exception was thrown from a ruby callback in a ruby/tk application, as the tk error dialog box showed only the error message itself and no backtrace. I have had to modify TkCore.callback() to reveal the backtrace. Don't you miss this information? Can this be done in another way? If not, then here is the simple patch, maybe it can be put into the mainstream code. ------------------------------------------------------------------ root@domesticus:/usr/lib/ruby/1.8# diff -u tk.rb.old tk.rb --- tk.rb.old 2003-10-09 01:18:38.000000000 +0200 +++ tk.rb 2003-10-09 01:40:47.000000000 +0200 @@ -772,7 +772,13 @@ #_get_eval_string(TkUtil.eval_cmd(TkCore::INTERP.tk_cmd_tbl[arg.shift], # *arg)) cb_obj = TkCore::INTERP.tk_cmd_tbl[arg.shift] - cb_obj.call(*arg) + begin + cb_obj.call(*arg) + rescue + # Append the backtrace to the message, so it can be displayed in the + # Tk error dialog window. + raise $!, "#{$!} - backtrace: \n#{$!.backtrace.join("\n")}" + end end def load_cmd_on_ip(tk_cmd) ------------------------------------------------------------------ Bye: Ferenc