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

Content added Content deleted
Line 2,074: Line 2,074:
val .U1 = h{"msg": "U1"}
val .U1 = h{"msg": "U1"}


val .baz = f(.i) throw if(.i==0: .U0; .U1)
val .baz = fn(.i) throw if(.i==0: .U0; .U1)
val .bar = f(.i) .baz(.i)
val .bar = fn(.i) .baz(.i)


val .foo = f() {
val .foo = impure fn() {
for .i in [0, 1] {
for .i in [0, 1] {
.bar(.i)
.bar(.i)
catch {
catch {
if _err["msg"] == .U0["msg"] {
if _err'msg == .U0'msg {
writeln "caught .U0 in .foo()"
writeln "caught .U0 in .foo()"
} else {
} else {
Line 2,090: Line 2,090:
}
}


.foo()</syntaxhighlight>
.foo()
</syntaxhighlight>


{{out}}
{{out}}