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

m
(Add Factor example)
Line 886:
</pre>
=={{header|Elena}}==
ELENA 3.4.x :
<lang elena>import extensions.;
class U0 :: Exception.;
class U1 :: Exception.;
singleton Exceptions
{
static int i.;
bar()
<= baz.();
baz()
[{
if (i == 0)
[{
U0 .new; ().raise()
];}
[else
U1 new; raise{
] U1.new().raise()
] }
] }
foo()
[{
for(i := 0., i < 2, i += 1)
while (i < 2){
[ try
try(self bar)
{
onself.bar(U0 e)
[}
console printLinecatch("U0 Caught"e).
]{
} console.printLine("U0 Caught")
try(self bar)}
i += 1.}
} ]
]
}
public program()
{
[
Exceptions foo.foo()
]}</lang>
{{out}}
<pre>
Anonymous user