]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/application.cpp
Trap and explain uncaught exceptions
[libs/core.git] / source / core / application.cpp
index 1012ea20f8b3ae400ead7b23fec92af737e8c2c2..0ef3443e8eac4fab7173b15df42c9cd1360b4e88 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id$
+
 This file is part of libmspcore
 Copyright © 2006 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
@@ -47,9 +48,20 @@ int Application::run(int argc, char **argv)
                return 1;
        }
 
-       int result=app_->main();
-       delete app_;
-       return result;
+       try
+       {
+               int result=app_->main();
+               delete app_;
+               return result;
+       }
+       catch(const exception &e)
+       {
+               cerr<<"An uncaught exception occurred.\n";
+               cerr<<"  type:   "<<typeid(e).name()<<'\n';
+               cerr<<"  what(): "<<e.what()<<'\n';
+               delete app_;
+               throw;
+       }
 }
 
 /**