[Orxonox-commit 2467] r7174 - in code/trunk/src: libraries/core libraries/core/input libraries/tools libraries/util orxonox/graphics orxonox/sound orxonox/worldentities

rgrieder at orxonox.net rgrieder at orxonox.net
Wed Aug 18 00:08:05 CEST 2010


Author: rgrieder
Date: 2010-08-18 00:08:05 +0200 (Wed, 18 Aug 2010)
New Revision: 7174

Modified:
   code/trunk/src/libraries/core/IRC.cc
   code/trunk/src/libraries/core/TclBind.cc
   code/trunk/src/libraries/core/TclThreadManager.cc
   code/trunk/src/libraries/core/input/InputDevice.h
   code/trunk/src/libraries/core/input/InputManager.cc
   code/trunk/src/libraries/tools/ResourceLocation.cc
   code/trunk/src/libraries/util/Exception.cc
   code/trunk/src/orxonox/graphics/ParticleEmitter.cc
   code/trunk/src/orxonox/sound/SoundManager.cc
   code/trunk/src/orxonox/worldentities/BigExplosion.cc
   code/trunk/src/orxonox/worldentities/ExplosionChunk.cc
Log:
Only catch exceptions you actually expect. And rethrow unknown exceptions ("..." can also catch internal Microsoft exceptions like floating point exception).


Modified: code/trunk/src/libraries/core/IRC.cc
===================================================================
--- code/trunk/src/libraries/core/IRC.cc	2010-08-17 18:56:32 UTC (rev 7173)
+++ code/trunk/src/libraries/core/IRC.cc	2010-08-17 22:08:05 UTC (rev 7174)
@@ -65,8 +65,6 @@
         }
         catch (Tcl::tcl_error const &e)
         {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
-        catch (...)
-        {   COUT(1) << "Error while initializing Tcl (IRC): " << Exception::handleMessage();   }
 
         this->nickname_ = "orx" + multi_cast<std::string>(static_cast<unsigned int>(rand()));
         TclThreadManager::execute(threadID, "set nickname " + this->nickname_);
@@ -95,8 +93,6 @@
         }
         catch (Tcl::tcl_error const &e)
         {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
-        catch (...)
-        {   COUT(1) << "Error while executing Tcl (IRC): " << Exception::handleMessage();   }
 
         return false;
     }

Modified: code/trunk/src/libraries/core/TclBind.cc
===================================================================
--- code/trunk/src/libraries/core/TclBind.cc	2010-08-17 18:56:32 UTC (rev 7173)
+++ code/trunk/src/libraries/core/TclBind.cc	2010-08-17 22:08:05 UTC (rev 7174)
@@ -92,8 +92,6 @@
             }
             catch (Tcl::tcl_error const &e)
             {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl;   }
-            catch (...)
-            {   COUT(1) << "Error while creating Tcl-interpreter: " << Exception::handleMessage() << std::endl;   }
         }
     }
 
@@ -113,8 +111,6 @@
         }
         catch (Tcl::tcl_error const &e)
         {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl; COUT(1) << "Error: Tcl isn't properly initialized. Orxonox might possibly not work like that." << std::endl;   }
-        catch (...)
-        {   COUT(1) << "Error while creating Tcl-interpreter: " << Exception::handleMessage() << std::endl; COUT(1) << "Error: Tcl isn't properly initialized. Orxonox might possibly not work like that." << std::endl;   }
 
         return interpreter;
     }
@@ -174,8 +170,6 @@
             }
             catch (Tcl::tcl_error const &e)
             {   COUT(1) << "tcl> Error: " << e.what() << std::endl;   }
-            catch (...)
-            {   COUT(1) << "Error while executing Tcl: " << Exception::handleMessage() << std::endl;   }
         }
 
         return "";
@@ -195,8 +189,6 @@
         }
         catch (Tcl::tcl_error const &e)
         {   COUT(1) << "Tcl error: " << e.what() << std::endl;   }
-        catch (...)
-        {   COUT(1) << "Error while executing Tcl: " << Exception::handleMessage() << std::endl;   }
 
         return false;
     }

Modified: code/trunk/src/libraries/core/TclThreadManager.cc
===================================================================
--- code/trunk/src/libraries/core/TclThreadManager.cc	2010-08-17 18:56:32 UTC (rev 7173)
+++ code/trunk/src/libraries/core/TclThreadManager.cc	2010-08-17 22:08:05 UTC (rev 7174)
@@ -286,8 +286,6 @@
         }
         catch (const Tcl::tcl_error& e)
         {   bundle->interpreter_ = 0; COUT(1) << "Tcl error while creating Tcl-interpreter (" << id_string << "): " << e.what() << std::endl;   }
-        catch (...)
-        {   bundle->interpreter_ = 0; COUT(1) << "Error while creating Tcl-interpreter (" << id_string << "): " << Exception::handleMessage() << std::endl;   }
     }
 
     /**

Modified: code/trunk/src/libraries/core/input/InputDevice.h
===================================================================
--- code/trunk/src/libraries/core/input/InputDevice.h	2010-08-17 18:56:32 UTC (rev 7173)
+++ code/trunk/src/libraries/core/input/InputDevice.h	2010-08-17 22:08:05 UTC (rev 7174)
@@ -39,6 +39,7 @@
 
 #include <vector>
 #include <ois/OISInputManager.h>
+#include <ois/OISException.h>
 
 #include "util/Clock.h"
 #include "util/Debug.h"
@@ -143,9 +144,9 @@
             {
                 oisInputManager_->destroyInputObject(oisDevice_);
             }
-            catch (...)
+            catch (const OIS::Exception& ex)
             {
-                COUT(1) << this->getClassName() << " destruction failed: " << Exception::handleMessage() << std::endl
+                COUT(1) << this->getClassName() << " destruction failed: " << ex.eText << std::endl
                         << "    Potential resource leak!" << std::endl;
             }
         }

Modified: code/trunk/src/libraries/core/input/InputManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/InputManager.cc	2010-08-17 18:56:32 UTC (rev 7173)
+++ code/trunk/src/libraries/core/input/InputManager.cc	2010-08-17 22:08:05 UTC (rev 7174)
@@ -305,17 +305,9 @@
             if (device == NULL)
                 continue;
             const std::string& className = device->getClassName();
-            try
-            {
-                delete device;
-                device = 0;
-                CCOUT(4) << className << " destroyed." << std::endl;
-            }
-            catch (...)
-            {
-                COUT(1) << className << " destruction failed: " << Exception::handleMessage() << std::endl
-                        << "    Potential resource leak!" << std::endl;
-            }
+            delete device;
+            device = 0;
+            CCOUT(4) << className << " destroyed." << std::endl;
         }
         devices_.resize(InputDeviceEnumerator::FirstJoyStick);
 
@@ -324,9 +316,9 @@
         {
             OIS::InputManager::destroyInputSystem(oisInputManager_);
         }
-        catch (...)
+        catch (const OIS::Exception& ex)
         {
-            COUT(1) << "OIS::InputManager destruction failed" << Exception::handleMessage() << std::endl
+            COUT(1) << "OIS::InputManager destruction failed" << ex.eText << std::endl
                     << "    Potential resource leak!" << std::endl;
         }
         oisInputManager_ = NULL;

Modified: code/trunk/src/libraries/tools/ResourceLocation.cc
===================================================================
--- code/trunk/src/libraries/tools/ResourceLocation.cc	2010-08-17 18:56:32 UTC (rev 7173)
+++ code/trunk/src/libraries/tools/ResourceLocation.cc	2010-08-17 22:08:05 UTC (rev 7174)
@@ -97,9 +97,9 @@
             Ogre::ResourceGroupManager::getSingleton().removeResourceLocation(
                 this->getPath(), this->getResourceGroup());
         }
-        catch (...)
+        catch (const Ogre::Exception& ex)
         {
-            COUT(1) << "Removing of a ResourceLocation failed: " << Exception::handleMessage() << std::endl;
+            COUT(1) << "Removing of a ResourceLocation failed: " << ex.what() << std::endl;
         }
     }
 }

Modified: code/trunk/src/libraries/util/Exception.cc
===================================================================
--- code/trunk/src/libraries/util/Exception.cc	2010-08-17 18:56:32 UTC (rev 7173)
+++ code/trunk/src/libraries/util/Exception.cc	2010-08-17 22:08:05 UTC (rev 7174)
@@ -33,7 +33,9 @@
 */
 
 #include "Exception.h"
+
 #include <CEGUIExceptions.h>
+#include "Debug.h"
 
 namespace orxonox
 {
@@ -114,7 +116,9 @@
         }
         catch (...)
         {
-            return "Unknown exception";
+            COUT(0) << "BIG WARNING: Unknown exception type encountered."
+                    << "Rethrowing" << endl;
+            throw;
         }
     }
 }

Modified: code/trunk/src/orxonox/graphics/ParticleEmitter.cc
===================================================================
--- code/trunk/src/orxonox/graphics/ParticleEmitter.cc	2010-08-17 18:56:32 UTC (rev 7173)
+++ code/trunk/src/orxonox/graphics/ParticleEmitter.cc	2010-08-17 22:08:05 UTC (rev 7174)
@@ -113,10 +113,10 @@
                 this->particles_->setVisible(this->isVisible());
                 this->particles_->setEnabled(this->isActive());
             }
-            catch (...)
+            catch (const std::exception& ex)
             {
                 COUT(1) << "Error: Couln't load particle effect \"" << this->source_ << "\" because:" << std::endl
-                        << Exception::handleMessage() << std::endl;
+                        << ex.what() << std::endl;
             }
         }
     }

Modified: code/trunk/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/trunk/src/orxonox/sound/SoundManager.cc	2010-08-17 18:56:32 UTC (rev 7173)
+++ code/trunk/src/orxonox/sound/SoundManager.cc	2010-08-17 22:08:05 UTC (rev 7174)
@@ -520,9 +520,9 @@
             {
                 buffer.reset(new SoundBuffer(filename, this->effectsPool_.end()));
             }
-            catch (...)
+            catch (const std::exception& ex)
             {
-                COUT(1) << Exception::handleMessage() << std::endl;
+                COUT(1) << ex.what() << std::endl;
                 return buffer;
             }
             this->soundBuffers_[filename] = buffer;

Modified: code/trunk/src/orxonox/worldentities/BigExplosion.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/BigExplosion.cc	2010-08-17 18:56:32 UTC (rev 7173)
+++ code/trunk/src/orxonox/worldentities/BigExplosion.cc	2010-08-17 22:08:05 UTC (rev 7174)
@@ -71,9 +71,9 @@
             {
                 this->init();
             }
-            catch (...)
+            catch (const std::exception& ex)
             {
-                COUT(1) << "Error: Couln't load particle effect in BigExplosion: " << Exception::handleMessage() << std::endl;
+                COUT(1) << "Error: Couln't load particle effect in BigExplosion: " << ex.what() << std::endl;
                 this->initZero();
             }
         }

Modified: code/trunk/src/orxonox/worldentities/ExplosionChunk.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/ExplosionChunk.cc	2010-08-17 18:56:32 UTC (rev 7173)
+++ code/trunk/src/orxonox/worldentities/ExplosionChunk.cc	2010-08-17 22:08:05 UTC (rev 7174)
@@ -58,9 +58,9 @@
                 this->smoke_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/smoke7", this->LOD_);
                 this->attachOgreObject(this->smoke_->getParticleSystem());
             }
-            catch (...)
+            catch (const std::exception& ex)
             {
-                COUT(1) << "Error: Couln't load particle effect in ExplosionChunk: " << Exception::handleMessage() << std::endl;
+                COUT(1) << "Error: Couln't load particle effect in ExplosionChunk: " << ex.what() << std::endl;
                 this->fire_ = 0;
                 this->smoke_ = 0;
             }




More information about the Orxonox-commit mailing list