diff options
| author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-16 14:53:47 +0000 |
|---|---|---|
| committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-16 14:53:47 +0000 |
| commit | 4c78e0d25fe147710d27718cb8d9030d4bfdfea1 (patch) | |
| tree | af3e6df4076e303b02052630bbeb3f1c42947e7e /ext/tk/lib | |
| parent | 02f3caf091a4bb56a05920a4a3e72669571ec048 (diff) | |
| download | ruby-4c78e0d25fe147710d27718cb8d9030d4bfdfea1.tar.gz ruby-4c78e0d25fe147710d27718cb8d9030d4bfdfea1.tar.xz ruby-4c78e0d25fe147710d27718cb8d9030d4bfdfea1.zip | |
If $DEBUG == true and some exception is caused in a callback
operation, Ruby/Tk shows a (verbose) backtrace information on
the callback process.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib')
| -rw-r--r-- | ext/tk/lib/tk.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index e904278b2..039461117 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -772,7 +772,23 @@ module TkCore #_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) + unless $DEBUG + cb_obj.call(*arg) + else + begin + raise 'check backtrace' + rescue + # ignore backtrace before 'callback' + pos = -($!.backtrace.size) + end + begin + cb_obj.call(*arg) + rescue + trace = $!.backtrace + raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" + + "\tfrom #{trace[1..pos].join("\n\tfrom ")}" + end + end end def load_cmd_on_ip(tk_cmd) |
