]> git.mxchange.org Git - simgear.git/commitdiff
Don't let exceptions escape from commands.
authorThomas Geymayer <tomgey@gmail.com>
Sun, 13 Oct 2013 10:00:52 +0000 (12:00 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Sun, 13 Oct 2013 10:00:52 +0000 (12:00 +0200)
simgear/structure/commands.cxx

index ae0001f92c7ce68299c7fd951ba0b1e5f62dbf19..f293c16b264324ec344d93eaa53f1f3a7cfb0089 100644 (file)
@@ -85,16 +85,45 @@ SGCommandMgr::execute (const std::string &name, const SGPropertyNode * arg) cons
 {
   Command* command = getCommand(name);
   if (command == 0)
+  {
+    SG_LOG(SG_GENERAL, SG_WARN, "command not found: '" << name << "'");
     return false;
+  }
 
-
-  try {
+  try
+  {
     return (*command)(arg);
-  } catch (sg_exception& e) {
-    SG_LOG(SG_GENERAL, SG_ALERT, "command '" << name << "' failed with exception\n"
-      << "\tmessage:" << e.getMessage() << " (from " << e.getOrigin() << ")");
-    return false;
   }
+  catch(sg_exception& e)
+  {
+    SG_LOG
+    (
+      SG_GENERAL,
+      SG_ALERT,
+      "command '" << name << "' failed with exception\n"
+      "\tmessage:" << e.getMessage() << " (from " << e.getOrigin() << ")"
+    );
+  }
+  catch(std::exception& ex)
+  {
+    SG_LOG
+    (
+      SG_GENERAL,
+      SG_ALERT,
+      "command '" << name << "' failed with exception: " << ex.what()
+    );
+  }
+  catch(...)
+  {
+    SG_LOG
+    (
+      SG_GENERAL,
+      SG_ALERT,
+      "command '" << name << "' failed with unknown exception."
+    );
+  }
+
+  return false;
 }
 
 // end of commands.cxx