]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/application.cpp
Report uncaught exceptions with a MessageBox on win32
[libs/core.git] / source / core / application.cpp
index 5acae82242b0a6d4106c7d647460934fd6acae12..cc9946cb32c7410a3f8e30fbd568728b55ee2c82 100644 (file)
@@ -4,8 +4,10 @@ This file is part of libmspcore
 Copyright © 2006 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
+
 #include <signal.h>
 #include <iostream>
+#include <typeinfo>
 #include "../debug/backtrace.h"
 #include "../debug/demangle.h"
 #include "../time/units.h"
@@ -60,6 +62,12 @@ int Application::run(int argc, char **argv, void *data)
        }
        catch(const exception &e)
        {
+               delete app_;
+
+#ifdef WIN32
+               string msg=Debug::demangle(typeid(e).name())+":\n"+e.what();
+               MessageBox(0, msg.c_str(), "Uncaught exception", MB_OK|MB_ICONERROR);
+#else
                cerr<<"An uncaught exception occurred.\n";
                cerr<<"  type:   "<<Debug::demangle(typeid(e).name())<<'\n';
                cerr<<"  what(): "<<e.what()<<'\n';
@@ -77,8 +85,8 @@ int Application::run(int argc, char **argv, void *data)
                                cerr<<" from "<<i->file<<'\n';
                        }
                }
+#endif
 
-               delete app_;
                return 124;
        }
 }