Changeset 5747
- Timestamp:
- Sep 19, 2009, 11:17:51 PM (15 years ago)
- Location:
- code/trunk/src
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/Orxonox.cc
r5738 r5747 45 45 46 46 #include "util/Debug.h" 47 #include "util/Exception.h" 47 48 #include "orxonox/Main.h" 48 49 … … 67 68 #endif 68 69 } 69 catch (const std::exception& ex)70 {71 COUT(0) << "Orxonox failed to initialise: " << ex.what() << std::endl;72 COUT(0) << "Terminating program." << std::endl;73 return 1;74 }75 70 catch (...) 76 71 { 77 COUT(0) << "Orxonox failed to initialise: " << std::endl;72 COUT(0) << "Orxonox failed to initialise: " << orxonox::Exception::handleMessage() << std::endl; 78 73 COUT(0) << "Terminating program." << std::endl; 79 74 return 1; -
code/trunk/src/libraries/core/Core.cc
r5738 r5747 284 284 DynLibManager::getInstance().load(librarypath.string()); 285 285 } 286 catch (const std::exception& e)287 {288 COUT(1) << "Couldn't load module \"" << librarypath.string() << "\": " << e.what() << std::endl;289 }290 286 catch (...) 291 287 { 292 COUT(1) << "Couldn't load module \"" << librarypath.string() << "\" "<< std::endl;288 COUT(1) << "Couldn't load module \"" << librarypath.string() << "\": " << Exception::handleMessage() << std::endl; 293 289 } 294 290 } … … 298 294 } 299 295 } 300 catch (const std::exception& e)301 {302 COUT(1) << "An error occurred while loading modules: " << e.what() << std::endl;303 }304 296 catch (...) 305 297 { 306 COUT(1) << "An error occurred while loading modules ."<< std::endl;298 COUT(1) << "An error occurred while loading modules: " << Exception::handleMessage() << std::endl; 307 299 } 308 300 … … 398 390 catch (...) 399 391 { 400 COUT(0) << "An exception occurred during ' new GraphicsManager' while "401 << " another exception was being handled. This willlead to undefined behaviour!" << std::endl392 COUT(0) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << std::endl 393 << "Another exception might be being handled which may lead to undefined behaviour!" << std::endl 402 394 << "Terminating the program." << std::endl; 403 395 abort(); -
code/trunk/src/libraries/core/Game.cc
r5738 r5747 37 37 #include <exception> 38 38 #include <boost/weak_ptr.hpp> 39 #include <CEGUIExceptions.h>40 39 41 40 #include "util/Debug.h" … … 204 203 catch (...) 205 204 { 206 COUT(0) << "An exception occurred in the Core preUpdate: " << Game::getExceptionMessage() << std::endl;205 COUT(0) << "An exception occurred in the Core preUpdate: " << Exception::handleMessage() << std::endl; 207 206 COUT(0) << "This should really never happen! Closing the program." << std::endl; 208 207 this->stop(); … … 218 217 catch (...) 219 218 { 220 COUT(0) << "An exception occurred in the Core postUpdate: " << Game::getExceptionMessage() << std::endl;221 COUT(0) << "This should really never happen! Closing the program." << std::endl;219 COUT(0) << "An exception occurred in the Core postUpdate: " << Exception::handleMessage() << std::endl; 220 COUT(0) << "This should really never happen! Closing the program." << std::endl; 222 221 this->stop(); 223 222 break; … … 254 253 catch (...) 255 254 { 256 COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << Game::getExceptionMessage() << std::endl;255 COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << Exception::handleMessage() << std::endl; 257 256 // All scheduled operations have now been rendered inert --> flush them and issue a warning 258 257 if (this->requestedStateNodes_.size() > 1) … … 285 284 catch (...) 286 285 { 287 COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << Game::getExceptionMessage() << std::endl;286 COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << Exception::handleMessage() << std::endl; 288 287 COUT(1) << "This should really never happen!" << std::endl; 289 288 COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl; … … 593 592 catch (...) 594 593 { 595 COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << Game::getExceptionMessage() << std::endl;594 COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << Exception::handleMessage() << std::endl; 596 595 COUT(2) << " There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl; 597 596 } … … 608 607 } 609 608 610 /*static*/ std::string Game::getExceptionMessage()611 {612 std::string exceptionMessage;613 try614 {615 // rethrow616 throw;617 }618 catch (const std::exception& ex)619 {620 return ex.what();621 }622 catch (const CEGUI::Exception& ex)623 {624 #if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6625 return GeneralException(ex.getMessage().c_str()).getDescription();626 #else627 return GeneralException(ex.getMessage().c_str(), ex.getLine(),628 ex.getFileName().c_str(), ex.getName().c_str()).getDescription();629 #endif630 }631 catch (...)632 {633 return "Unknown exception";634 }635 }636 637 609 std::map<std::string, shared_ptr<Game::GameStateFactory> > Game::GameStateFactory::factories_s; 638 610 -
code/trunk/src/libraries/core/Game.h
r5738 r5747 155 155 // ScopeGuard helper function 156 156 void resetChangingState() { this->bChangingState_ = false; } 157 /**158 @brief159 Retrieves information from an exception caught with "..."160 @remarks161 Never ever call this function without an exception in the stack!162 */163 static std::string getExceptionMessage();164 157 165 158 scoped_ptr<Clock> gameClock_; -
code/trunk/src/libraries/core/GraphicsManager.cc
r5738 r5747 172 172 // scripts for the 1.6 version and then remove the inserted "particle_system" 173 173 // keyword. But we need to supply these new scripts as well, which is why 174 // there is an extra Ogre::Archive dealing with i n the memory.174 // there is an extra Ogre::Archive dealing with it in the memory. 175 175 using namespace Ogre; 176 176 ArchiveManager::getSingleton().addArchiveFactory(memoryArchiveFactory_.get()); -
code/trunk/src/libraries/core/IRC.cc
r5738 r5747 32 32 33 33 #include "util/Convert.h" 34 #include "util/Exception.h" 34 35 #include "ConsoleCommand.h" 35 36 #include "CoreIncludes.h" … … 64 65 catch (Tcl::tcl_error const &e) 65 66 { COUT(1) << "Tcl (IRC) error: " << e.what(); } 66 catch ( std::exception const &e)67 { COUT(1) << "Error while initializing Tcl (IRC): " << e.what(); }67 catch (...) 68 { COUT(1) << "Error while initializing Tcl (IRC): " << Exception::handleMessage(); } 68 69 69 70 this->nickname_ = "orx" + multi_cast<std::string>(static_cast<unsigned int>(rand())); … … 94 95 catch (Tcl::tcl_error const &e) 95 96 { COUT(1) << "Tcl (IRC) error: " << e.what(); } 96 catch ( std::exception const &e)97 { COUT(1) << "Error while executing Tcl (IRC): " << e.what(); }97 catch (...) 98 { COUT(1) << "Error while executing Tcl (IRC): " << Exception::handleMessage(); } 98 99 99 100 return false; -
code/trunk/src/libraries/core/Loader.cc
r5738 r5747 187 187 return false; 188 188 } 189 catch ( std::exception& ex)189 catch (...) 190 190 { 191 191 COUT(1) << std::endl; 192 192 COUT(1) << "An error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl; 193 COUT(1) << ex.what() << std::endl; 194 COUT(1) << "Loading aborted." << std::endl; 195 return false; 196 } 197 catch (...) 198 { 199 COUT(1) << std::endl; 200 COUT(1) << "An unknown error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl; 193 COUT(1) << Exception::handleMessage() << std::endl; 201 194 COUT(1) << "Loading aborted." << std::endl; 202 195 return false; -
code/trunk/src/libraries/core/TclBind.cc
r5738 r5747 35 35 #include "SpecialConfig.h" 36 36 #include "util/Debug.h" 37 #include "util/Exception.h" 37 38 #include "util/StringUtils.h" 38 39 #include "CommandExecutor.h" … … 92 93 catch (Tcl::tcl_error const &e) 93 94 { COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl; } 94 catch (std::exception const &e)95 { COUT(1) << "Error while creating Tcl-interpreter: " << e.what() << std::endl; }96 95 catch (...) 97 { COUT(1) << "Error while creating Tcl-interpreter ."<< std::endl; }96 { COUT(1) << "Error while creating Tcl-interpreter: " << Exception::handleMessage() << std::endl; } 98 97 } 99 98 } … … 115 114 catch (Tcl::tcl_error const &e) 116 115 { 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; } 117 catch (std::exception const &e)118 { COUT(1) << "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; }119 116 catch (...) 120 { COUT(1) << "Error while creating Tcl-interpreter ."<< std::endl; COUT(1) << "Error: Tcl isn't properly initialized. Orxonox might possibly not work like that." << std::endl; }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; } 121 118 122 119 return interpreter; … … 178 175 catch (Tcl::tcl_error const &e) 179 176 { COUT(1) << "tcl> Error: " << e.what() << std::endl; } 180 catch ( std::exception const &e)181 { COUT(1) << "Error while executing Tcl: " << e.what() << std::endl; }177 catch (...) 178 { COUT(1) << "Error while executing Tcl: " << Exception::handleMessage() << std::endl; } 182 179 } 183 180 … … 199 196 catch (Tcl::tcl_error const &e) 200 197 { COUT(1) << "Tcl error: " << e.what() << std::endl; } 201 catch ( std::exception const &e)202 { COUT(1) << "Error while executing Tcl: " << e.what() << std::endl; }198 catch (...) 199 { COUT(1) << "Error while executing Tcl: " << Exception::handleMessage() << std::endl; } 203 200 204 201 return false; -
code/trunk/src/libraries/core/TclThreadManager.cc
r5738 r5747 37 37 38 38 #include "util/Convert.h" 39 #include "util/Exception.h" 39 40 #include "Clock.h" 40 41 #include "CommandExecutor.h" … … 285 286 catch (const Tcl::tcl_error& e) 286 287 { bundle->interpreter_ = 0; COUT(1) << "Tcl error while creating Tcl-interpreter (" << id_string << "): " << e.what() << std::endl; } 287 catch (const std::exception& e)288 { bundle->interpreter_ = 0; COUT(1) << "Error while creating Tcl-interpreter (" << id_string << "): " << e.what() << std::endl; }289 288 catch (...) 290 { bundle->interpreter_ = 0; COUT(1) << " An error occurred while creating a new Tcl-interpreter (" << id_string << ")"<< std::endl; }289 { bundle->interpreter_ = 0; COUT(1) << "Error while creating Tcl-interpreter (" << id_string << "): " << Exception::handleMessage() << std::endl; } 291 290 } 292 291 -
code/trunk/src/libraries/core/XMLPort.h
r5738 r5747 591 591 throw ex; 592 592 } 593 catch ( std::exception& ex)593 catch (...) 594 594 { 595 595 COUT(1) << "An error occurred while loading object:" << std::endl; 596 COUT(1) << ex.what() << std::endl; 597 } 598 catch (...) 599 { 600 COUT(1) << "An unknown error occurred while loading object." << std::endl; 596 COUT(1) << Exception::handleMessage() << std::endl; 601 597 } 602 598 } -
code/trunk/src/libraries/core/input/InputDevice.h
r5738 r5747 42 42 43 43 #include "util/Debug.h" 44 #include "util/Exception.h" 44 45 #include "core/Clock.h" 45 46 #include "InputState.h" … … 145 146 catch (...) 146 147 { 147 COUT(1) << this->getClassName() << " destruction failed! Potential resource leak!" << std::endl; 148 COUT(1) << this->getClassName() << " destruction failed: " << Exception::handleMessage() << std::endl 149 << " Potential resource leak!" << std::endl; 148 150 } 149 151 } -
code/trunk/src/libraries/core/input/InputManager.cc
r5738 r5747 330 330 catch (...) 331 331 { 332 CCOUT(1) << className << " destruction failed! Potential resource leak!" << std::endl; 332 COUT(1) << className << " destruction failed: " << Exception::handleMessage() << std::endl 333 << " Potential resource leak!" << std::endl; 333 334 } 334 335 } … … 342 343 catch (...) 343 344 { 344 CCOUT(1) << "OIS::InputManager destruction failed! Potential resource leak!" << std::endl; 345 COUT(1) << "OIS::InputManager destruction failed" << Exception::handleMessage() << std::endl 346 << " Potential resource leak!" << std::endl; 345 347 } 346 348 oisInputManager_ = NULL; -
code/trunk/src/libraries/tools/ResourceLocation.cc
r5738 r5747 97 97 this->getPath(), this->getResourceGroup()); 98 98 } 99 catch ( const std::exception& ex)99 catch (...) 100 100 { 101 COUT(1) << "Removing of a ResourceLocation failed: " << ex.what() << std::endl;101 COUT(1) << "Removing of a ResourceLocation failed: " << Exception::handleMessage() << std::endl; 102 102 } 103 103 } -
code/trunk/src/libraries/util/CMakeLists.txt
r5738 r5747 74 74 "UTIL_SHARED_BUILD" 75 75 LINK_LIBRARIES 76 ${CEGUI_LIBRARY} 76 77 ${OGRE_LIBRARY} 77 78 SOURCE_FILES -
code/trunk/src/libraries/util/Exception.cc
r5738 r5747 34 34 35 35 #include "Exception.h" 36 #include <CEGUIExceptions.h> 36 37 37 38 namespace orxonox … … 93 94 return getDescription().c_str(); 94 95 } 96 97 /*static*/ std::string Exception::handleMessage() 98 { 99 try 100 { 101 // rethrow 102 throw; 103 } 104 catch (const std::exception& ex) 105 { 106 return ex.what(); 107 } 108 catch (const CEGUI::Exception& ex) 109 { 110 #if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6 111 return GeneralException(ex.getMessage().c_str()).getDescription(); 112 #else 113 return GeneralException(ex.getMessage().c_str(), ex.getLine(), 114 ex.getFileName().c_str(), ex.getName().c_str()).getDescription(); 115 #endif 116 } 117 catch (...) 118 { 119 return "Unknown exception"; 120 } 121 } 95 122 } -
code/trunk/src/libraries/util/Exception.h
r5738 r5747 83 83 virtual const std::string& getFilename() const { return this->filename_; } 84 84 85 /** 86 @brief 87 Retrieves information from an exception caught with "..." 88 Works for std::exception and CEGUI::Exception 89 @remarks 90 Never ever call this function without an exception in the stack! 91 */ 92 static std::string handleMessage(); 93 85 94 protected: 86 95 std::string description_; //!< User typed text about why the exception occurred -
code/trunk/src/orxonox/graphics/ParticleEmitter.cc
r5738 r5747 110 110 { 111 111 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), this->source_, this->LOD_); 112 this->attachOgreObject(this->particles_->getParticleSystem());113 this->particles_->setVisible(this->isVisible());114 this->particles_->setEnabled(this->isActive());115 112 } 116 113 catch (...) 117 114 { 118 COUT(1) << "Error: Couln't load particle effect \"" << this->source_ << "\" " << std::endl;119 this->particles_ = 0;115 COUT(1) << "Error: Couln't load particle effect \"" << this->source_ << "\" because:" << std::endl 116 << Exception::handleMessage() << std::endl; 120 117 } 118 this->attachOgreObject(this->particles_->getParticleSystem()); 119 this->particles_->setVisible(this->isVisible()); 120 this->particles_->setEnabled(this->isActive()); 121 121 } 122 122 } -
code/trunk/src/orxonox/worldentities/BigExplosion.cc
r5738 r5747 74 74 catch (...) 75 75 { 76 COUT(1) << "Error: Couln't load particle effect in BigExplosion ."<< std::endl;76 COUT(1) << "Error: Couln't load particle effect in BigExplosion: " << Exception::handleMessage() << std::endl; 77 77 this->initZero(); 78 78 } … … 97 97 void BigExplosion::init() 98 98 { 99 Identifier* idDE1 = Class(MovableEntity); 100 BaseObject* oDE1 = idDE1->fabricate(this); 101 this->debrisEntity1_ = orxonox_cast<MovableEntity*>(oDE1); 102 103 Identifier* idDE2 = Class(MovableEntity); 104 BaseObject* oDE2 = idDE2->fabricate(this); 105 this->debrisEntity2_ = orxonox_cast<MovableEntity*>(oDE2); 106 107 Identifier* idDE3 = Class(MovableEntity); 108 BaseObject* oDE3 = idDE3 ->fabricate(this); 109 this->debrisEntity3_ = orxonox_cast<MovableEntity*>(oDE3); 110 111 Identifier* idDE4 = Class(MovableEntity); 112 BaseObject* oDE4 = idDE4->fabricate(this); 113 this->debrisEntity4_ = orxonox_cast<MovableEntity*>(oDE4); 114 115 Identifier* idD1 = Class(Model); 116 BaseObject* oD1 = idD1->fabricate(this); 117 this->debris1_ = orxonox_cast<Model*>(oD1); 118 119 Identifier* idD2 = Class(Model); 120 BaseObject* oD2 = idD2->fabricate(this); 121 this->debris2_ = orxonox_cast<Model*>(oD2); 122 123 Identifier* idD3 = Class(Model); 124 BaseObject* oD3 = idD3->fabricate(this); 125 this->debris3_ = orxonox_cast<Model*>(oD3); 126 127 Identifier* idD4 = Class(Model); 128 BaseObject* oD4 = idD4->fabricate(this); 129 this->debris4_ = orxonox_cast<Model*>(oD4); 130 131 Identifier* id6 = Class(StaticEntity); 132 BaseObject* object4 = id6->fabricate(this); 133 this->explosion_ = orxonox_cast<StaticEntity*>(object4); 99 this->debrisEntity1_ = new MovableEntity(this); 100 this->debrisEntity2_ = new MovableEntity(this); 101 this->debrisEntity3_ = new MovableEntity(this); 102 this->debrisEntity4_ = new MovableEntity(this); 103 104 this->debris1_ = new Model(this); 105 this->debris2_ = new Model(this); 106 this->debris3_ = new Model(this); 107 this->debris4_ = new Model(this); 108 109 this->explosion_ = new StaticEntity(this); 134 110 135 111 this->debrisSmoke1_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/smoke7", this->LOD_); … … 200 176 for(int i=0;i<10;i++) 201 177 { 202 Identifier* idf1 = Class(Model); 203 BaseObject* obj1 = idf1->fabricate(this); 204 Model* part1 = orxonox_cast<Model*>(obj1); 205 206 207 Identifier* idf2 = Class(Model); 208 BaseObject* obj2 = idf2->fabricate(this); 209 Model* part2 = orxonox_cast<Model*>(obj2); 210 211 Identifier* idf3 = Class(MovableEntity); 212 BaseObject* obj3 = idf3->fabricate(this); 213 MovableEntity* partEntity1 = orxonox_cast<MovableEntity*>(obj3); 214 215 Identifier* idf4 = Class(MovableEntity); 216 BaseObject* obj4 = idf4->fabricate(this); 217 MovableEntity* partEntity2 = orxonox_cast<MovableEntity*>(obj4); 178 Model* part1 = new Model(this); 179 Model* part2 = new Model(this); 180 181 MovableEntity* partEntity1 = new MovableEntity(this); 182 MovableEntity* partEntity2 = new MovableEntity(this); 218 183 219 184 partEntity1->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(10,100)); … … 227 192 part1->setMeshSource("SmallPart1.mesh"); 228 193 part2->setMeshSource("SmallPart2.mesh"); 229 230 194 231 195 partEntity1->attach(part1); -
code/trunk/src/orxonox/worldentities/ExplosionChunk.cc
r5738 r5747 61 61 catch (...) 62 62 { 63 COUT(1) << "Error: Couln't load particle effect in ExplosionChunk ."<< std::endl;63 COUT(1) << "Error: Couln't load particle effect in ExplosionChunk: " << Exception::handleMessage() << std::endl; 64 64 this->fire_ = 0; 65 65 this->smoke_ = 0;
Note: See TracChangeset
for help on using the changeset viewer.