diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-01-24 10:43:22 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 11:02:39 +1000 |
commit | c52b491011be94e796ce8c28a16249ca62256084 (patch) | |
tree | 194336bdc3b89bd7a299174785938209a68127cf /tcl6.tcl | |
parent | 16360e9b8aded842ab0d343969eb13354750b5bb (diff) | |
download | jimtcl-c52b491011be94e796ce8c28a16249ca62256084.zip jimtcl-c52b491011be94e796ce8c28a16249ca62256084.tar.gz jimtcl-c52b491011be94e796ce8c28a16249ca62256084.tar.bz2 |
Improve error handling
*: Improve stack trace handling on errors
*: Add 'info source'
*: Add 'info stacktrace'
*: Add errorInfo procedure to generate a human readable stack trace
*: Add tests for stacktrace
------------------------------------------------------------------------
Diffstat (limited to 'tcl6.tcl')
-rw-r--r-- | tcl6.tcl | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -84,4 +84,25 @@ proc parray {arrayname {pattern *}} { } } +# Sort of replacement for $::errorInfo +proc errorInfo {error} { + set result "Runtime Error: $error" + foreach {l f p} [lreverse [info stacktrace]] { + append result \n + if {$p ne ""} { + append result "in procedure '$p' " + if {$f ne ""} { + append result "called " + } + } + if {$f ne ""} { + append result "at file \"$f\", line $l" + } + } + if {[info exists f] && $f ne ""} { + return "$f:$l: $result" + } + return $result +} + set ::tcl_platform(platform) unix |