]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/application.cpp
Move most platform-specific code into overlay directories
[libs/core.git] / source / core / application.cpp
index 6bfa6289f1174b604293c09464bd9746d783e46e..36621e92ae99af9b74a2726263fd3b8176cbd020 100644 (file)
@@ -1,10 +1,5 @@
-#ifdef WIN32
-#include <windows.h>
-#endif
 #include <signal.h>
-#include <iostream>
-#include <typeinfo>
-#include <msp/debug/demangle.h>
+#include <msp/io/print.h>
 #include "application.h"
 #include "getopt.h"
 
@@ -33,14 +28,14 @@ int Application::run(int argc, char **argv, void *data)
        static bool called = false;
        if(called)
        {
-               cerr<<"Trying to call Application::run_app twice!\n";
+               IO::cerr.write("Trying to call Application::run_app twice!\n");
                return 125;
        }
        called = true;
 
        if(!starter_)
        {
-               cerr<<"Trying to run with no RegisteredApplication class!\n";
+               IO::cerr.write("Trying to run with no RegisteredApplication class!\n");
                return 126;
        }
 
@@ -54,8 +49,7 @@ int Application::run(int argc, char **argv, void *data)
                }
                catch(const usage_error &e)
                {
-                       cerr<<e.what()<<'\n';
-                       cerr<<e.help()<<'\n';
+                       IO::print(IO::cerr, "%s\n%s\n", e.what(), e.help());
                        return 1;
                }
 
@@ -69,14 +63,7 @@ int Application::run(int argc, char **argv, void *data)
        {
                delete app_;
 
-#ifdef WIN32
-               string msg = Debug::demangle(typeid(e).name())+":\n"+e.what();
-               MessageBoxA(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';
-#endif
+               display_exception(e);
 
                return 124;
        }