import std.stdio; import std.conv; import std.exception; void main() { try { foo(); } catch (Exception e) { for (Throwable t = e; t !is null; t = t.next) { writeln(t); } } }
void foo() { try { throw new Exception("thrown from foo"); } finally { bar(3); } } void bar(int x) { try { throw new Exception(text("thrown from bar #", x)); } finally { if (x > 1) { bar(x - 1); } } } DMD 2.052, XP 32bit: object.Exception@test.d(26): thrown from foo object.Exception@test.d(38): thrown from bar #3 object.Exception@test.d(38): thrown from bar #2 object.Exception@test.d(38): thrown from bar #1 object.Exception@test.d(38): thrown from bar #3 object.Exception@test.d(38): thrown from bar #2 object.Exception@test.d(38): thrown from bar #1 object.Exception@test.d(38): thrown from bar #2 object.Exception@test.d(38): thrown from bar #1 object.Exception@test.d(38): thrown from bar #1 Simply calling writeln(e) will work: void main() { try { foo(); } catch (Exception e) { writeln(e); } } writes: object.Exception@test.d(27): thrown from foo object.Exception@test.d(39): thrown from bar #3 object.Exception@test.d(39): thrown from bar #2 object.Exception@test.d(39): thrown from bar #1 However that doesn't help if you want to iterate through the exceptions one at a time.