www.pudn.com > zfxcengine-0.1.0.zip > ceExceptions.cpp
/* $Id: ceExceptions.cpp,v 1.4 2005/09/03 14:24:14 kimmi Exp $ */ //////////////////////////////////////////////////////////////////////////////// // // ceExceptions.cpp // Implemetierung der Exceptions-Verwaltung // History of changes: // - 06.05.2003 by Created Clemens Scherer // - 26.05.2003 Changed by Clemens Scherer // - 19.12.2003 Changed by Clemens Scherer (std::string) // //////////////////////////////////////////////////////////////////////////////// #include#include "Core/ceExceptions.h" #include "Core/ceLogSystem.h" #include "Core/ceCoreTools.h" #include "Core/ceMemManager.h" namespace ZFXCE { //////////////////////////////////////////////////////////////////////////////// using namespace std; //////////////////////////////////////////////////////////////////////////////// ceException::ceException(const std::string strFile,unsigned int nLine, const std::string strErrorDesc, unsigned int nLevel) { PUSH_FUNCTION; // Setze Attribute m_strFile = strFile; m_strErrorDesc = strErrorDesc; m_strErrorText = ""; m_nLine = nLine; m_nLevel = nLevel; GenerateErrorText(); WriteErrorToLog(); } //////////////////////////////////////////////////////////////////////////////// ceException::~ceException(void) { PUSH_FUNCTION; } //////////////////////////////////////////////////////////////////////////////// void ceException::GenerateErrorText(void) { PUSH_FUNCTION; std::ostringstream strErrStream; strErrStream << std::endl << "E R R O R File: " << m_strFile << std::endl << " Line: " << m_nLine << std::endl << " Description: " << m_strErrorDesc << std::endl << " Level: " << GetLevelText(m_nLevel) << std::endl << " Stack: " << Debug::LogCrashedFunction(FALSE) << std::endl << std::endl; m_strErrorText = strErrStream.str(); } //////////////////////////////////////////////////////////////////////////////// void ceException::WriteErrorToLog(void) { PUSH_FUNCTION; if (0 == m_strErrorText.size()) GenerateErrorText(); WriteLog(m_strErrorText); #ifdef WIN32 ::MessageBox(NULL,m_strErrorText.c_str(),"ZFXC-Engine",MB_OK); #endif } //////////////////////////////////////////////////////////////////////////////// string ceException::GetLevelText(unsigned int nLevel) { PUSH_FUNCTION; switch(nLevel) { case CELS_WARNING: return "Warning"; case CELS_LOWERROR: return "Low Error"; case CELS_ERROR: return "Error"; case CELS_HARDERROR: return "Hard Error"; } return "Unknown Error - Please report a bug."; } //////////////////////////////////////////////////////////////////////////////// string ceException::GetText() { PUSH_FUNCTION; if (0 == m_strErrorText.size()) GenerateErrorText(); return m_strErrorText; } } // Namespace ZFXCE