Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7174 for code/trunk/src


Ignore:
Timestamp:
Aug 18, 2010, 12:08:05 AM (14 years ago)
Author:
rgrieder
Message:

Only catch exceptions you actually expect. And rethrow unknown exceptions ("…" can also catch internal Microsoft exceptions like floating point exception).

Location:
code/trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/IRC.cc

    r6417 r7174  
    6666        catch (Tcl::tcl_error const &e)
    6767        {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
    68         catch (...)
    69         {   COUT(1) << "Error while initializing Tcl (IRC): " << Exception::handleMessage();   }
    7068
    7169        this->nickname_ = "orx" + multi_cast<std::string>(static_cast<unsigned int>(rand()));
     
    9694        catch (Tcl::tcl_error const &e)
    9795        {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
    98         catch (...)
    99         {   COUT(1) << "Error while executing Tcl (IRC): " << Exception::handleMessage();   }
    10096
    10197        return false;
  • code/trunk/src/libraries/core/TclBind.cc

    r6417 r7174  
    9393            catch (Tcl::tcl_error const &e)
    9494            {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl;   }
    95             catch (...)
    96             {   COUT(1) << "Error while creating Tcl-interpreter: " << Exception::handleMessage() << std::endl;   }
    9795        }
    9896    }
     
    114112        catch (Tcl::tcl_error const &e)
    115113        {   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;   }
    116         catch (...)
    117         {   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;   }
    118114
    119115        return interpreter;
     
    175171            catch (Tcl::tcl_error const &e)
    176172            {   COUT(1) << "tcl> Error: " << e.what() << std::endl;   }
    177             catch (...)
    178             {   COUT(1) << "Error while executing Tcl: " << Exception::handleMessage() << std::endl;   }
    179173        }
    180174
     
    196190        catch (Tcl::tcl_error const &e)
    197191        {   COUT(1) << "Tcl error: " << e.what() << std::endl;   }
    198         catch (...)
    199         {   COUT(1) << "Error while executing Tcl: " << Exception::handleMessage() << std::endl;   }
    200192
    201193        return false;
  • code/trunk/src/libraries/core/TclThreadManager.cc

    r7165 r7174  
    287287        catch (const Tcl::tcl_error& e)
    288288        {   bundle->interpreter_ = 0; COUT(1) << "Tcl error while creating Tcl-interpreter (" << id_string << "): " << e.what() << std::endl;   }
    289         catch (...)
    290         {   bundle->interpreter_ = 0; COUT(1) << "Error while creating Tcl-interpreter (" << id_string << "): " << Exception::handleMessage() << std::endl;   }
    291289    }
    292290
  • code/trunk/src/libraries/core/input/InputDevice.h

    r6746 r7174  
    4040#include <vector>
    4141#include <ois/OISInputManager.h>
     42#include <ois/OISException.h>
    4243
    4344#include "util/Clock.h"
     
    144145                oisInputManager_->destroyInputObject(oisDevice_);
    145146            }
    146             catch (...)
     147            catch (const OIS::Exception& ex)
    147148            {
    148                 COUT(1) << this->getClassName() << " destruction failed: " << Exception::handleMessage() << std::endl
     149                COUT(1) << this->getClassName() << " destruction failed: " << ex.eText << std::endl
    149150                        << "    Potential resource leak!" << std::endl;
    150151            }
  • code/trunk/src/libraries/core/input/InputManager.cc

    r6746 r7174  
    306306                continue;
    307307            const std::string& className = device->getClassName();
    308             try
    309             {
    310                 delete device;
    311                 device = 0;
    312                 CCOUT(4) << className << " destroyed." << std::endl;
    313             }
    314             catch (...)
    315             {
    316                 COUT(1) << className << " destruction failed: " << Exception::handleMessage() << std::endl
    317                         << "    Potential resource leak!" << std::endl;
    318             }
     308            delete device;
     309            device = 0;
     310            CCOUT(4) << className << " destroyed." << std::endl;
    319311        }
    320312        devices_.resize(InputDeviceEnumerator::FirstJoyStick);
     
    325317            OIS::InputManager::destroyInputSystem(oisInputManager_);
    326318        }
    327         catch (...)
    328         {
    329             COUT(1) << "OIS::InputManager destruction failed" << Exception::handleMessage() << std::endl
     319        catch (const OIS::Exception& ex)
     320        {
     321            COUT(1) << "OIS::InputManager destruction failed" << ex.eText << std::endl
    330322                    << "    Potential resource leak!" << std::endl;
    331323        }
  • code/trunk/src/libraries/tools/ResourceLocation.cc

    r6417 r7174  
    9898                this->getPath(), this->getResourceGroup());
    9999        }
    100         catch (...)
     100        catch (const Ogre::Exception& ex)
    101101        {
    102             COUT(1) << "Removing of a ResourceLocation failed: " << Exception::handleMessage() << std::endl;
     102            COUT(1) << "Removing of a ResourceLocation failed: " << ex.what() << std::endl;
    103103        }
    104104    }
  • code/trunk/src/libraries/util/Exception.cc

    r6417 r7174  
    3434
    3535#include "Exception.h"
     36
    3637#include <CEGUIExceptions.h>
     38#include "Debug.h"
    3739
    3840namespace orxonox
     
    115117        catch (...)
    116118        {
    117             return "Unknown exception";
     119            COUT(0) << "BIG WARNING: Unknown exception type encountered."
     120                    << "Rethrowing" << endl;
     121            throw;
    118122        }
    119123    }
  • code/trunk/src/orxonox/graphics/ParticleEmitter.cc

    r5929 r7174  
    114114                this->particles_->setEnabled(this->isActive());
    115115            }
    116             catch (...)
     116            catch (const std::exception& ex)
    117117            {
    118118                COUT(1) << "Error: Couln't load particle effect \"" << this->source_ << "\" because:" << std::endl
    119                         << Exception::handleMessage() << std::endl;
     119                        << ex.what() << std::endl;
    120120            }
    121121        }
  • code/trunk/src/orxonox/sound/SoundManager.cc

    r6417 r7174  
    521521                buffer.reset(new SoundBuffer(filename, this->effectsPool_.end()));
    522522            }
    523             catch (...)
    524             {
    525                 COUT(1) << Exception::handleMessage() << std::endl;
     523            catch (const std::exception& ex)
     524            {
     525                COUT(1) << ex.what() << std::endl;
    526526                return buffer;
    527527            }
  • code/trunk/src/orxonox/worldentities/BigExplosion.cc

    r7171 r7174  
    7272                this->init();
    7373            }
    74             catch (...)
    75             {
    76                 COUT(1) << "Error: Couln't load particle effect in BigExplosion: " << Exception::handleMessage() << std::endl;
     74            catch (const std::exception& ex)
     75            {
     76                COUT(1) << "Error: Couln't load particle effect in BigExplosion: " << ex.what() << std::endl;
    7777                this->initZero();
    7878            }
  • code/trunk/src/orxonox/worldentities/ExplosionChunk.cc

    r5929 r7174  
    5959                this->attachOgreObject(this->smoke_->getParticleSystem());
    6060            }
    61             catch (...)
     61            catch (const std::exception& ex)
    6262            {
    63                 COUT(1) << "Error: Couln't load particle effect in ExplosionChunk: " << Exception::handleMessage() << std::endl;
     63                COUT(1) << "Error: Couln't load particle effect in ExplosionChunk: " << ex.what() << std::endl;
    6464                this->fire_ = 0;
    6565                this->smoke_ = 0;
Note: See TracChangeset for help on using the changeset viewer.