fork download
  1. import std.stdio, std.exception;
  2.  
  3. struct Catcher {
  4. ~this() {
  5. try {} catch (Exception e) {
  6. writeln("Woooo!");
  7. throw e;
  8. }
  9. scope (failure) {
  10. writeln("Woooo woooo!");
  11. }
  12. writeln("Destructing...");
  13. }
  14. }
  15.  
  16. void main() {
  17. scope (failure) writeln("Sensible");
  18. scope (exit) writeln("Always written");
  19. Catcher c1;
  20. scope auto c2 = Catcher();
  21. throw new Exception("Foobar");
  22. }
Runtime error #stdin #stdout #stderr 0s 4100KB
stdin
Standard input is empty
stdout
Destructing...
Destructing...
Always written
Sensible
stderr
object.Exception@prog.d(21): Foobar
----------------
0x0 libbacktrace could not find executable to open
	???:0
0x804d0ad ???
	???:0
0x8051e50 ???
	???:0
0x805216d ???
	???:0
0x80523b0 ???
	???:0
0x805216d ???
	???:0
0x80522e8 ???
	???:0
0x804cf5f ???
	???:0
0xb76e0722 ???
	???:0
0x804ce65 ???
	???:0