28 #ifndef __Exception_H_
29 #define __Exception_H_
38 #if OGRE_RELEASE_ASSERT == 1
39 # define OGRE_ASSERT_MODE 1
45 #if OGRE_ASSERT_MODE == 1
47 # define OgreAssert( a, b ) assert( (a) && (b) )
50 # if OGRE_COMP != OGRE_COMPILER_BORL
51 # define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info")
53 # define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ )
59 #elif OGRE_ASSERT_MODE == 2
60 # if OGRE_COMP != OGRE_COMPILER_BORL
61 # define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info")
63 # define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ )
68 # define OgreAssert( a, b ) assert( (a) && (b) )
127 Exception(
int number,
const String& description,
const String& source,
const char* type,
const char* file,
long line );
150 virtual const String& getFullDescription(
void)
const;
154 virtual int getNumber(
void)
const throw();
158 virtual const
String &getSource()
const {
return source; }
175 const char*
what()
const throw() {
return getFullDescription().c_str(); }
199 :
Exception(inNumber, inDescription, inSource,
"UnimplementedException", inFile, inLine) {}
205 :
Exception(inNumber, inDescription, inSource,
"FileNotFoundException", inFile, inLine) {}
211 :
Exception(inNumber, inDescription, inSource,
"IOException", inFile, inLine) {}
217 :
Exception(inNumber, inDescription, inSource,
"InvalidStateException", inFile, inLine) {}
223 :
Exception(inNumber, inDescription, inSource,
"InvalidParametersException", inFile, inLine) {}
229 :
Exception(inNumber, inDescription, inSource,
"ItemIdentityException", inFile, inLine) {}
235 :
Exception(inNumber, inDescription, inSource,
"InternalErrorException", inFile, inLine) {}
241 :
Exception(inNumber, inDescription, inSource,
"RenderingAPIException", inFile, inLine) {}
247 :
Exception(inNumber, inDescription, inSource,
"RuntimeAssertionException", inFile, inLine) {}
269 const String& src,
const char* file,
long line)
276 const String& src,
const char* file,
long line)
283 const String& src,
const char* file,
long line)
290 const String& src,
const char* file,
long line)
297 const String& src,
const char* file,
long line)
304 const String& src,
const char* file,
long line)
311 const String& src,
const char* file,
long line)
318 const String& src,
const char* file,
long line)
325 const String& src,
const char* file,
long line)
332 const String& src,
const char* file,
long line)
342 #define OGRE_EXCEPT(num, desc, src) throw Ogre::ExceptionFactory::create( \
343 Ogre::ExceptionCodeType<num>(), desc, src, __FILE__, __LINE__ );
IOException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
UnimplementedException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
static FileNotFoundException create(ExceptionCodeType< Exception::ERR_FILE_NOT_FOUND > code, const String &desc, const String &src, const char *file, long line)
ItemIdentityException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
InvalidStateException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
static ItemIdentityException create(ExceptionCodeType< Exception::ERR_ITEM_NOT_FOUND > code, const String &desc, const String &src, const char *file, long line)
RenderingAPIException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
static RuntimeAssertionException create(ExceptionCodeType< Exception::ERR_RT_ASSERTION_FAILED > code, const String &desc, const String &src, const char *file, long line)
const char * what() const
Override std::exception::what.
static InvalidParametersException create(ExceptionCodeType< Exception::ERR_INVALIDPARAMS > code, const String &desc, const String &src, const char *file, long line)
virtual const String & getDescription(void) const
Returns a string with only the 'description' field of this exception.
static IOException create(ExceptionCodeType< Exception::ERR_CANNOT_WRITE_TO_FILE > code, const String &desc, const String &src, const char *file, long line)
RuntimeAssertionException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
virtual long getLine() const
Gets line number.
ExceptionFactory()
Private constructor, no construction.
static UnimplementedException create(ExceptionCodeType< Exception::ERR_NOT_IMPLEMENTED > code, const String &desc, const String &src, const char *file, long line)
virtual const String & getFile() const
Gets source file name.
static InternalErrorException create(ExceptionCodeType< Exception::ERR_INTERNAL_ERROR > code, const String &desc, const String &src, const char *file, long line)
Class implementing dispatch methods in order to construct by-value exceptions of a derived type based...
static InvalidStateException create(ExceptionCodeType< Exception::ERR_INVALID_STATE > code, const String &desc, const String &src, const char *file, long line)
static RenderingAPIException create(ExceptionCodeType< Exception::ERR_RENDERINGAPI_ERROR > code, const String &desc, const String &src, const char *file, long line)
InternalErrorException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
Template struct which creates a distinct type for each exception code.
static ItemIdentityException create(ExceptionCodeType< Exception::ERR_DUPLICATE_ITEM > code, const String &desc, const String &src, const char *file, long line)
FileNotFoundException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
~Exception()
Needed for compatibility with std::exception.
ExceptionCodes
Static definitions of error codes.
When thrown, provides information about an error that has occurred inside the engine.
InvalidParametersException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)