28 #ifndef __Exception_H_
29 #define __Exception_H_
40 #if OGRE_ASSERT_MODE == 1
42 # define OgreAssert( a, b ) assert( (a) && (b) )
44 # if OGRE_COMP != OGRE_COMPILER_BORL
45 # define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info")
47 # define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ )
52 #elif OGRE_ASSERT_MODE == 2
53 # if OGRE_COMP != OGRE_COMPILER_BORL
54 # define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info")
56 # define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ )
61 # define OgreAssert( a, b ) assert( (a) && (b) )
119 Exception(
int number,
const String& description,
const String& source,
const char* type,
const char* file,
long line );
167 const char*
what()
const throw() {
return getFullDescription().c_str(); }
191 :
Exception(inNumber, inDescription, inSource,
"UnimplementedException", inFile, inLine) {}
197 :
Exception(inNumber, inDescription, inSource,
"FileNotFoundException", inFile, inLine) {}
203 :
Exception(inNumber, inDescription, inSource,
"IOException", inFile, inLine) {}
209 :
Exception(inNumber, inDescription, inSource,
"InvalidStateException", inFile, inLine) {}
215 :
Exception(inNumber, inDescription, inSource,
"InvalidParametersException", inFile, inLine) {}
221 :
Exception(inNumber, inDescription, inSource,
"ItemIdentityException", inFile, inLine) {}
227 :
Exception(inNumber, inDescription, inSource,
"InternalErrorException", inFile, inLine) {}
233 :
Exception(inNumber, inDescription, inSource,
"RenderingAPIException", inFile, inLine) {}
239 :
Exception(inNumber, inDescription, inSource,
"RuntimeAssertionException", inFile, inLine) {}
261 const String& src,
const char* file,
long line)
268 const String& src,
const char* file,
long line)
275 const String& src,
const char* file,
long line)
282 const String& src,
const char* file,
long line)
289 const String& src,
const char* file,
long line)
296 const String& src,
const char* file,
long line)
303 const String& src,
const char* file,
long line)
310 const String& src,
const char* file,
long line)
317 const String& src,
const char* file,
long line)
324 const String& src,
const char* file,
long line)
334 #define OGRE_EXCEPT(num, desc, src) throw Ogre::ExceptionFactory::create( \
335 Ogre::ExceptionCodeType<num>(), desc, src, __FILE__, __LINE__ );
Class implementing dispatch methods in order to construct by-value exceptions of a derived type based...
static UnimplementedException create(ExceptionCodeType< Exception::ERR_NOT_IMPLEMENTED > code, const String &desc, const String &src, const char *file, long line)
static InternalErrorException create(ExceptionCodeType< Exception::ERR_INTERNAL_ERROR > code, const String &desc, const String &src, const char *file, long line)
static InvalidParametersException create(ExceptionCodeType< Exception::ERR_INVALIDPARAMS > code, const String &desc, const String &src, const char *file, long line)
static IOException create(ExceptionCodeType< Exception::ERR_CANNOT_WRITE_TO_FILE > code, const String &desc, const String &src, const char *file, long line)
static ItemIdentityException create(ExceptionCodeType< Exception::ERR_ITEM_NOT_FOUND > 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)
static FileNotFoundException create(ExceptionCodeType< Exception::ERR_FILE_NOT_FOUND > code, const String &desc, const String &src, const char *file, long line)
ExceptionFactory()
Private constructor, no construction.
static ItemIdentityException create(ExceptionCodeType< Exception::ERR_DUPLICATE_ITEM > code, const String &desc, const String &src, const char *file, long line)
static RuntimeAssertionException create(ExceptionCodeType< Exception::ERR_RT_ASSERTION_FAILED > code, const String &desc, const String &src, const char *file, long line)
static InvalidStateException create(ExceptionCodeType< Exception::ERR_INVALID_STATE > code, const String &desc, const String &src, const char *file, long line)
When thrown, provides information about an error that has occurred inside the engine.
virtual const String & getDescription(void) const
Returns a string with only the 'description' field of this exception.
const char * what() const
Override std::exception::what.
~Exception()
Needed for compatibility with std::exception.
virtual const String & getFile() const
Gets source file name.
Exception(const Exception &rhs)
Copy constructor.
ExceptionCodes
Static definitions of error codes.
@ ERR_CANNOT_WRITE_TO_FILE
@ ERR_RT_ASSERTION_FAILED
Exception(int number, const String &description, const String &source, const char *type, const char *file, long line)
Advanced constructor.
virtual int getNumber(void) const
Gets the error code.
virtual const String & getSource() const
Gets the source function.
Exception(int number, const String &description, const String &source)
Default constructor.
virtual long getLine() const
Gets line number.
virtual const String & getFullDescription(void) const
Returns a string with the full description of this error.
FileNotFoundException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
IOException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
InternalErrorException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
InvalidParametersException(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)
ItemIdentityException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
RenderingAPIException(int inNumber, const String &inDescription, const String &inSource, const char *inFile, long inLine)
RuntimeAssertionException(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)
Template struct which creates a distinct type for each exception code.