Exceptions/Catch an exception thrown in a nested call: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: added syntax colouring the hard way, phix/basics) |
|||
Line 852: | Line 852: | ||
=={{header|Dyalect}}== |
=={{header|Dyalect}}== |
||
<lang dyalect> |
<lang dyalect>var bazCallCount = 0 |
||
type U1() |
|||
var bazCallCount = 0 |
|||
func baz() { |
func baz() { |
||
bazCallCount += 1 |
bazCallCount += 1 |
||
if bazCallCount == 1 { |
if bazCallCount == 1 { |
||
throw |
throw "Err0" |
||
} else if bazCallCount == 2 { |
} else if bazCallCount == 2 { |
||
throw |
throw "Err1" |
||
} |
} |
||
} |
} |
||
func bar() { |
func bar() { |
||
baz() |
baz() |
||
} |
} |
||
func foo() { |
func foo() { |
||
var calls = 2 |
var calls = 2 |
||
Line 875: | Line 873: | ||
bar() |
bar() |
||
} catch { |
} catch { |
||
UnexpectedError("Err0") => print("Err0 caught.") |
|||
} |
} |
||
calls -= 1 |
calls -= 1 |
||
} |
} |
||
} |
|||
⚫ | |||
⚫ | |||
{{out}} |
{{out}} |
||
<pre> |
<pre>Err0 caught. |
||
Runtime exception Dy601: |
Runtime exception Dy601: Err1 |
||
Stack trace: ...</pre> |
Stack trace: ...</pre> |
||