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

added langur language example
(→‎{{header|11l}}: Add link to discussion page section.)
(added langur language example)
Line 1,835:
at ExceptionsKt.main(exceptions.kt:28)
</pre>
 
=={{header|Langur}}==
Exceptions in langur are hashes that are guaranteed to always contain certain fields.
 
There is no explicit try block.
 
<lang Langur>val .U0 = h{"msg": "U0"}
val .U1 = h{"msg": "U1"}
 
val .baz = f(.i) throw if .i > 0 {.U1} else {.U0} ~ h{"src": ".baz"}
val .bar = f(.i) .baz(.i)
 
val .foo = f(.i) {
.bar(.i)
catch if .err["msg"] == .U0["msg"] {
writeln "caught .U0 in .foo()"
} else {
throw .err
}
}
 
.foo(0)
.foo(1)</lang>
 
{{out}}
<pre>caught .U0 in .foo()
VM Errors
general: U1 (.baz)</pre>
 
=={{header|Lasso}}==
890

edits