Exceptions/Catch an exception thrown in a nested call: Difference between revisions

→‎{{header|Ursala}}: Perfectly doable in TXR.
(Added Delphi example)
(→‎{{header|Ursala}}: Perfectly doable in TXR.)
Line 1,519:
"foo"
(file "exceptions.tcl" line 26)</pre>
 
=={{header|TXR}}==
 
<lang txr>@(defex u0)
@(defex u1)
@(define baz (x))
@ (cases)
@ (bind x "0")
@ (throw u0 "text0")
@ (or)
@ (bind x "1")
@ (throw u1 "text1")
@ (end)
@(end)
@(define bar (x))
@ (baz x)
@(end)
@(define foo ())
@ (next `!echo "0\n1\n"`)
@ (collect)
@num
@ (try)
@ (bar num)
@ (catch u0 (arg))
@ (output)
caught u0: @arg
@ (end)
@ (end)
@ (end)
@(end)
@(foo)</lang>
 
Run:
<pre>$ txr except.txr
caught u0: text0
txr: unhandled exception of type u1:
txr: ((t . "text1"))
Aborted
</pre>
 
=={{header|Ursala}}==
Anonymous user