Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 19, 2009, 11:17:51 PM (15 years ago)
Author:
rgrieder
Message:

Added Exception::handleMessage() (copy from Game::getExceptionMessage) function that returns the exception message (if retrievable) when catching with "…"
and adjusted some exception handlers.

File:
1 edited

Legend:

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

    r5738 r5747  
    3737#include <exception>
    3838#include <boost/weak_ptr.hpp>
    39 #include <CEGUIExceptions.h>
    4039
    4140#include "util/Debug.h"
     
    204203            catch (...)
    205204            {
    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;
    207206                COUT(0) << "This should really never happen! Closing the program." << std::endl;
    208207                this->stop();
     
    218217            catch (...)
    219218            {
    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;
    222221                this->stop();
    223222                break;
     
    254253                catch (...)
    255254                {
    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;
    257256                    // All scheduled operations have now been rendered inert --> flush them and issue a warning
    258257                    if (this->requestedStateNodes_.size() > 1)
     
    285284            catch (...)
    286285            {
    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;
    288287                COUT(1) << "This should really never happen!" << std::endl;
    289288                COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl;
     
    593592        catch (...)
    594593        {
    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;
    596595            COUT(2) << "         There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl;
    597596        }
     
    608607    }
    609608
    610     /*static*/ std::string Game::getExceptionMessage()
    611     {
    612         std::string exceptionMessage;
    613         try
    614         {
    615             // rethrow
    616             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 < 6
    625             return GeneralException(ex.getMessage().c_str()).getDescription();
    626 #else
    627             return GeneralException(ex.getMessage().c_str(), ex.getLine(),
    628                 ex.getFileName().c_str(), ex.getName().c_str()).getDescription();
    629 #endif
    630         }
    631         catch (...)
    632         {
    633             return "Unknown exception";
    634         }
    635     }
    636 
    637609    std::map<std::string, shared_ptr<Game::GameStateFactory> > Game::GameStateFactory::factories_s;
    638610
Note: See TracChangeset for help on using the changeset viewer.