Anonymous user
Exceptions/Catch an exception thrown in a nested call: Difference between revisions
Exceptions/Catch an exception thrown in a nested call (view source)
Revision as of 13:08, 8 August 2019
, 4 years agoAdded Dyalect programming language
Langurmonkey (talk | contribs) |
(Added Dyalect programming language) |
||
Line 774:
<pre>Exception1 caught
User defined exception: Error message 2</pre>
=={{header|Dyalect}}==
<lang dyalect>type U0()
type U1()
var bazCallCount = 0
func baz() {
bazCallCount += 1
if bazCallCount == 1 {
throw U0()
} else if bazCallCount == 2 {
throw U1()
}
}
func bar() {
baz()
}
func foo() {
var calls = 2
while calls > 0 {
try {
bar()
} catch {
U0() => print("U0 caught.")
}
calls -= 1
}
}</lang>
{{out}}
<pre>U0 caught.
Runtime exception Dy601: U1
Stack trace: ...</pre>
=={{header|EchoLisp}}==
|