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

Content added Content deleted
(Added Quackery.)
Line 857: Line 857:
bazCallCount += 1
bazCallCount += 1
if bazCallCount == 1 {
if bazCallCount == 1 {
throw "Err0"
throw Error.BazCall1()
} else if bazCallCount == 2 {
} else if bazCallCount == 2 {
throw "Err1"
throw Error.BazCall2()
}
}
}
}
Line 873: Line 873:
bar()
bar()
} catch {
} catch {
UnexpectedError("Err0") => print("Err0 caught.")
BazCall1() => print("BazzCall1 caught.")
}
}
calls -= 1
calls -= 1
}
}
}
}

foo()</lang>
foo()</lang>


{{out}}
{{out}}


<pre>Err0 caught.
<pre>BazzCall1 caught.
Runtime exception Dy601: Err1
Unhandled exception. Runtime exception Dy601: BazCall2
Stack trace: ...</pre>
Stack trace: ...</pre>