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 22:12, 14 June 2013
, 10 years agoFixed and updated D entry
(Fixed and updated D entry) |
|||
Line 509:
=={{header|D}}==
First exception will be caught and message will be displayed, second will be caught by default exception handler.
<lang d>
this() @safe pure nothrow { super("U0 error message"); }▼
▲ this() nothrow { super("U0 error message"); }
}
class U1 : Exception {
this() @safe pure nothrow { super("U1 error message"); }
}
void foo(
throw new U1;▼
}▼
foreach (immutable i; 0 .. 2) {▼
void bar(in int i) pure {▼
foo(i);▼
}▼
▲ foreach (i; 0 .. 2) {
try {
} catch (U0
}
}
▲}
▲void bar(in int i) @safe pure {
▲}
void baz(in int i) @safe pure {
}
void main() {
}</lang>
{{output}}
<pre>test.U1
----------------
\test.d(20): pure void test.bar(int)
|