From 06a5f9188d656b69ede3f7ea93fbf8cbcb203a1a Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Sun, 13 Oct 2013 12:00:52 +0200 Subject: [PATCH] Don't let exceptions escape from commands. --- simgear/structure/commands.cxx | 41 +++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/simgear/structure/commands.cxx b/simgear/structure/commands.cxx index ae0001f9..f293c16b 100644 --- a/simgear/structure/commands.cxx +++ b/simgear/structure/commands.cxx @@ -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 -- 2.39.5