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

Line 51:
=={{header|Aime}}==
<lang aime>void
baz(integer i, text &exception)
{
exception = error(cat("U", itoa(i)));
error(exception);
}
 
void
bar(integer i, text &exception)
{
baz(i, exception);
}
 
Line 70 ⟶ 69:
i = 0;
while (i < 2) {
text e;
 
if (traptrap_d(bare, ibar, ei)) {
o_form("Exception `~' thrown\n", e);
if (e != "U0") {
Line 93 ⟶ 92:
}</lang>
{{out}}
<pre>aime:Exception tmp/nce:`U0' 5: U0thrown
Exception `U0' thrown
aime: tmp/nce: 5: U1
Exception `U1' thrown
will not catch exception
aime: tmp/ncenec: 2926: U1</pre>
Exception U0 is caught, exception U1 is caught and re-thrown. Program execution is terminated as the U1 exception is not caught when thrown the second time.
 
Anonymous user