Exceptions: Difference between revisions
Content deleted Content added
Line 771: | Line 771: | ||
val x = f() handle MyException => 22; |
val x = f() handle MyException => 22; |
||
val y = f() handle MyDataException x => x; |
val y = f() handle MyDataException x => x; |
||
=={{header|Tcl}}== |
|||
<lang tcl>package require Tcl 8.5 |
|||
# Throw |
|||
proc e {args} { |
|||
error "error message" "error message for stack trace" {errorCode list} |
|||
} |
|||
# Catch and rethrow |
|||
proc f {} { |
|||
if {[catch {e 1 2 3 4} errMsg options] != 0} { |
|||
return -options $options $errMsg |
|||
} |
|||
} |
|||
f</lang> |
|||
This creates the stack trace |
|||
<pre>error message for stack trace |
|||
(procedure "e" line 1) |
|||
invoked from within |
|||
"e 1 2 3 4" |
|||
(procedure "f" line 2) |
|||
invoked from within |
|||
"f"</pre> |
|||
=={{header|V}}== |
=={{header|V}}== |