00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #ifndef __Exception_H_ 00026 #define __Exception_H_ 00027 00028 // Precompiler options 00029 #include "OgrePrerequisites.h" 00030 00031 #include "OgreString.h" 00032 00033 #define Except( num, desc, src ) throw( Ogre::Exception( num, desc, src, __FILE__, __LINE__ ) ) 00034 00035 // Stack unwinding options 00036 // OgreUnguard and OgreUnguardRet are deprecated 00037 #if OGRE_STACK_UNWINDING == 1 00038 # if OGRE_COMPILER != COMPILER_BORL 00039 # define OgreGuard( a ) Ogre::AutomaticGuardUnguard _auto_guard_object( (a) ) 00040 # else 00041 # define OgreGuard( a ) Ogre::AutomaticGuardUnguard _auto_guard_object( __FUNC__ ) 00042 # endif 00043 00044 # define OgreUnguard() 00045 # define OgreUnguardRet( a ) return a 00046 00047 #else 00048 # define OgreGuard( a ) 00049 # define OgreUnguard() 00050 # define OgreUnguardRet( a ) return a 00051 00052 #endif 00053 00054 // Release asserts - throw exceptions 00055 #if OGRE_RELEASE_ASSERT == 1 00056 # ifdef _DEBUG 00057 # define OgreAssert( a, b ) assert( (a) && (b) ) 00058 00059 # else 00060 # if OGRE_COMP != COMP_BORL 00061 # define OgreAssert( a, b ) if( !(a) ) Except( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info" ) 00062 # else 00063 # define OgreAssert( a, b ) if( !(a) ) Except( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ ) 00064 # endif 00065 00066 # endif 00067 00068 #else 00069 # define OgreAssert( a, b ) assert( (a) && (b) ) 00070 00071 #endif 00072 00073 #define OGRE_CALL_STACK_DEPTH 512 00074 00075 namespace Ogre { 00089 class _OgreExport Exception 00090 { 00091 protected: 00092 long line; 00093 int number; 00094 String description; 00095 String source; 00096 String file; 00097 ushort stackDepth; 00098 static Exception* last; 00099 00100 static OgreChar msFunctionStack[ OGRE_CALL_STACK_DEPTH ][ 256 ]; 00101 static ushort msStackDepth; 00102 public: 00108 enum ExceptionCodes { 00109 UNIMPLEMENTED_FEATURE, 00110 ERR_CANNOT_WRITE_TO_FILE, 00111 ERR_NO_RENDERSYSTEM_SELECTED, 00112 ERR_DIALOG_OPEN_ERROR, 00113 ERR_INVALIDPARAMS, 00114 ERR_RENDERINGAPI_ERROR, 00115 ERR_DUPLICATE_ITEM, 00116 ERR_ITEM_NOT_FOUND, 00117 ERR_FILE_NOT_FOUND, 00118 ERR_INTERNAL_ERROR, 00119 ERR_RT_ASSERTION_FAILED 00120 }; 00121 00124 Exception( int number, const String& description, const String& source ); 00125 00128 Exception( int number, const String& description, const String& source, char* file, long line ); 00129 00132 Exception(const Exception& rhs); 00133 00136 void operator = (const Exception& rhs); 00137 00148 String getFullDescription(void) const; 00149 00152 int getNumber(void) const throw(); 00153 00156 static Exception* getLastException(void) throw(); 00157 00160 static void _pushFunction( const String& strFuncName ) throw(); 00163 static void _popFunction() throw(); 00164 00165 }; 00166 00168 class _OgreExport AutomaticGuardUnguard { 00169 public: 00170 AutomaticGuardUnguard(const String& funcName) throw() 00171 { 00172 Exception::_pushFunction(funcName); 00173 } 00174 ~AutomaticGuardUnguard() throw() 00175 { 00176 Exception::_popFunction(); 00177 } 00178 }; 00179 00180 } // Namespace Ogre 00181 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:10 2004