fork(1) download
  1. #include <iostream>
  2. #include <exception>
  3. #include <stdexcept>
  4.  
  5. class Application {
  6. public:
  7. Application() {}
  8.  
  9. bool connect() {
  10. std::cout << "connecting" << std::endl;
  11. return true;
  12. }
  13.  
  14. void disconnect() {
  15. std::cout << "disconnecting" << std::endl;
  16. }
  17.  
  18. ~Application() {
  19. disconnect();
  20.  
  21. if (std::uncaught_exception()) {
  22. createCrashReport();
  23. }
  24. }
  25. protected:
  26. void createCrashReport() {
  27. std::cerr << "Application was halted by an exception" << std::endl;
  28. }
  29. };
  30.  
  31. void riskyThing() {
  32. throw std::runtime_error("Fuck you!");
  33. }
  34.  
  35. void foo() {
  36. Application app;
  37. app.connect();
  38.  
  39. riskyThing();
  40. }
  41.  
  42. int main() {
  43. foo();
  44.  
  45. return 0;
  46. }
Runtime error #stdin #stdout #stderr 0s 3428KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::runtime_error'
  what():  Fuck you!