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

m
imported>Arakov
Line 1,027:
 
=={{header|Elena}}==
ELENA 56.0x :
<syntaxhighlight lang="elena">import extensions;
class U0 : Exception
{
constructor new()
<= super new("U0 exception");
}
class U1 : Exception
{
constructor new()
<= super new("U1 exception");
}
singleton Exceptions
{
static int i;
bar()
<= baz();
baz()
{
if (i == 0)
{
U0.raise()
}
else
{
U1.raise()
}
}
foo()
{
for(i := 0, i < 2, i +:= i + 1)
{
try
{
self.bar()
}
catch(U0 e)
{
console.printLine("U0 Caught")
}
}
}
}
Line 1,084:
<pre>
U0 Caught
U1 exception
mytest'U1#class
Call stack:
mytestsandbox'$private'Exceptions.baz[01]:testsandbox.l(2130)
system'Exception#class.new$system'LiteralValue[1]:exceptions.l(124)
mytestsandbox'$private'Exceptions.foo[01]:testsandbox.l(3040)
system'Exception#class.new[0]:exceptions.l(128)
sandbox'program.function:#invoke:sandbox.l(52)
mytest'Exceptions.baz[0]:test.l(21)
system'$private'entry.function:#invoke:app.l(5)
mytest'Exceptions.bar[0]:test.l(12)
system'$private'entrySymbol#sym:app.l(23)
mytest'Exceptions.foo[0]:test.l(30)
 
mytest'program.eval[0]:test.l(45)
Aborted:ffffffff
system'#inline1AB.start[1]:win32_app.l(35)
system'startUp(1)
</pre>
 
Anonymous user