tuned error reporting a bit
authorPerttu Ahola <celeron55@gmail.com>
Sat, 23 Apr 2011 15:53:39 +0000 (18:53 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sat, 23 Apr 2011 15:53:39 +0000 (18:53 +0300)
src/main.cpp

index dd8d5d7d48423ce28bc04967ff08beb748e47d01..5349310d614558ae73705a458cf17bd78b4f46b0 100644 (file)
@@ -1248,18 +1248,18 @@ int main(int argc, char *argv[])
                GUI stuff\r
        */\r
 \r
+       /*\r
+               If an error occurs, this is set to something and the\r
+               menu-game loop is restarted. It is then displayed before\r
+               the menu.\r
+       */\r
+       std::wstring error_message = L"";\r
+\r
        /*\r
                Menu-game loop\r
        */\r
        while(device->run() && kill == false)\r
        {\r
-               /*\r
-                       If an error occurs, this is set to something and the\r
-                       menu-game loop is restarted. It is then displayed before\r
-                       the menu.\r
-               */\r
-               std::wstring error_message = L"";\r
-\r
                // This is used for catching disconnects\r
                try\r
                {\r
@@ -1404,6 +1404,21 @@ int main(int argc, char *argv[])
                        dstream<<DTIME<<"Connection error (timed out?)"<<std::endl;\r
                        error_message = L"Connection error (timed out?)";\r
                }\r
+               catch(SocketException &e)\r
+               {\r
+                       dstream<<DTIME<<"Socket error (port already in use?)"<<std::endl;\r
+                       error_message = L"Socket error (port already in use?)";\r
+               }\r
+#ifdef NDEBUG\r
+               catch(std::exception &e)\r
+               {\r
+                       narrow_message = "Some exception, what()=\"";\r
+                       narrow_message += e.what();\r
+                       narrow_message += "\"";\r
+                       dstream<<DTIME<<narrow_message<<std::endl;\r
+                       error_message = narrow_to_wide(narrow_message);\r
+               }\r
+#endif\r
 \r
        } // Menu-game loop\r
        \r