aboutsummaryrefslogtreecommitdiff
path: root/tcl6.tcl
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-01-24 10:43:22 +1000
committerSteve Bennett <steveb@workware.net.au>2010-10-15 11:02:39 +1000
commitc52b491011be94e796ce8c28a16249ca62256084 (patch)
tree194336bdc3b89bd7a299174785938209a68127cf /tcl6.tcl
parent16360e9b8aded842ab0d343969eb13354750b5bb (diff)
downloadjimtcl-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.tcl21
1 files changed, 21 insertions, 0 deletions
diff --git a/tcl6.tcl b/tcl6.tcl
index 4c41bc1..3d0f43c 100644
--- a/tcl6.tcl
+++ b/tcl6.tcl
@@ -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