]> Dogcows Code - chaz/yoink/blobdiff - src/YoinkApp.cc
better logging (maybe) and exception handling
[chaz/yoink] / src / YoinkApp.cc
index 626fe1aea9ab18e823c49635573a19dad9dfac8c..a17bf88b1c0ffe84c7ef52a2b966773e434f5ea7 100644 (file)
@@ -32,6 +32,8 @@
 
 #include <boost/bind.hpp>
 
+#include <Moof/Exception.hh>
+#include <Moof/Log.hh>
 #include <Moof/Math.hh>
 #include <Moof/OpenGL.hh>
 #include <Moof/Settings.hh>
@@ -138,7 +140,6 @@ YoinkApp::YoinkApp(int argc, char* argv[]) :
 
 YoinkApp::~YoinkApp()
 {
-       std::cerr << "yoinkapp destructor" << std::endl;
        //delete heroine;
        delete font;
        delete testScene;
@@ -457,26 +458,45 @@ void YoinkApp::handleEvent(const Mf::Event& event)
 
 int main(int argc, char* argv[])
 {
-       std::cout << PACKAGE_STRING << std::endl
+       std::cout << std::endl << PACKAGE_STRING << std::endl
                          << "Compiled " << __TIME__ " " __DATE__ << std::endl
                          << "Send patches and bug reports to <"
                          PACKAGE_BUGREPORT << ">." << std::endl << std::endl;
 
+#if ! NDEBUG
+       Mf::setLogLevel(Mf::DEBUGGING);
+#endif
+
        int status = 0;
 
+//start:
        try
        {
-               YoinkApp* app = new YoinkApp(argc, argv);
-               status = app->run();
-               delete app;
+               YoinkApp app(argc, argv);
+               status = app.run();
        }
-       catch (Mf::Engine::Exception e)
+       //catch (Mf::Texture::Exception e)
+       //{
+               //std::cout << "Unhandled exception: " << e.what() << std::endl;
+               //status = 1;
+       //}
+       catch (Mf::Exception e)
        {
-               std::cerr << "Unhandled exception: " << e.what() << std::endl;
+               //std::cout << "Unhandled exception: " << e.what() << std::endl;
+               Mf::logError("unhandled exception: <<%s>>", e.what());
+               Mf::logInfo("it's time to crash now ;-(");
                status = 1;
+
+               //std::cout << "Yoink stopped.  Do you want to run it again? [yes/No]"
+                       //<< std::endl;
+
+               //char answer;
+               //std::cin >> answer;
+
+               //if (answer == 'y' || answer == 'Y') goto start;
        }
 
-       std::cout << "Goodbye..." << std::endl;
+       std::cout << std::endl << "Goodbye..." << std::endl << std::endl;
        return status;
 }
 
This page took 0.019281 seconds and 4 git commands to generate.