X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fapplication.cpp;h=d5745ed8a36ae2cbe139a14de0f1ba76c1b22d5c;hp=6bfa6289f1174b604293c09464bd9746d783e46e;hb=0f5501ad79950e9658fb672ac6b97a608e3a2dd9;hpb=c7afef88380ebebc8c2b04e48664d73281ec8848 diff --git a/source/core/application.cpp b/source/core/application.cpp index 6bfa628..d5745ed 100644 --- a/source/core/application.cpp +++ b/source/core/application.cpp @@ -1,10 +1,8 @@ -#ifdef WIN32 -#include -#endif -#include -#include #include +#include #include +#include +#include #include "application.h" #include "getopt.h" @@ -18,29 +16,16 @@ void *Application::data_ = 0; Application::Application(): exit_code(0) -{ } - -/** -Constructs an instance of the registered application class and runs it. If the -application throws a usage_error, a help message is printed. The GetOpt class -will throw such exceptions automatically in error conditions. +{ + if(app_) + throw logic_error("instance already exists"); +} -This function can only be called once. The global main() function provided by -the library normally does it automatically at program startup. -*/ int Application::run(int argc, char **argv, void *data) { - static bool called = false; - if(called) - { - cerr<<"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("Application::run called with no RegisteredApplication class!\n"); return 126; } @@ -54,8 +39,7 @@ int Application::run(int argc, char **argv, void *data) } catch(const usage_error &e) { - cerr<report_uncaught_exception(e); -#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: "<sighandler(s);