/usr/include/OGRE/OgreException.h is in libogre-1.9-dev 1.9.0+dfsg1-7+b4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __Exception_H_
#define __Exception_H_
// Precompiler options
#include "OgrePrerequisites.h"
#include "OgreString.h"
#include <exception>
#include "OgreHeaderPrefix.h"
// Check for OGRE assert mode
// RELEASE_EXCEPTIONS mode
#if OGRE_ASSERT_MODE == 1
# if OGRE_DEBUG_MODE
# define OgreAssert( a, b ) assert( (a) && (b) )
# else
# if OGRE_COMP != OGRE_COMPILER_BORL
# define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info")
# else
# define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ )
# endif
# endif
// EXCEPTIONS mode
#elif OGRE_ASSERT_MODE == 2
# if OGRE_COMP != OGRE_COMPILER_BORL
# define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info")
# else
# define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ )
# endif
// STANDARD mode
#else
# define OgreAssert( a, b ) assert( (a) && (b) )
#endif
namespace Ogre {
/** \addtogroup Core
* @{
*/
/** \addtogroup General
* @{
*/
/** When thrown, provides information about an error that has occurred inside the engine.
@remarks
OGRE never uses return values to indicate errors. Instead, if an
error occurs, an exception is thrown, and this is the object that
encapsulates the detail of the problem. The application using
OGRE should always ensure that the exceptions are caught, so all
OGRE engine functions should occur within a
try{} catch(Ogre::Exception& e) {} block.
@par
The user application should never create any instances of this
object unless it wishes to unify its error handling using the
same object.
*/
class _OgreExport Exception : public std::exception
{
protected:
long line;
int number;
String typeName;
String description;
String source;
String file;
mutable String fullDesc;
public:
/** Static definitions of error codes.
@todo
Add many more exception codes, since we want the user to be able
to catch most of them.
*/
enum ExceptionCodes {
ERR_CANNOT_WRITE_TO_FILE,
ERR_INVALID_STATE,
ERR_INVALIDPARAMS,
ERR_RENDERINGAPI_ERROR,
ERR_DUPLICATE_ITEM,
ERR_ITEM_NOT_FOUND,
ERR_FILE_NOT_FOUND,
ERR_INTERNAL_ERROR,
ERR_RT_ASSERTION_FAILED,
ERR_NOT_IMPLEMENTED
};
/** Default constructor.
*/
Exception( int number, const String& description, const String& source );
/** Advanced constructor.
*/
Exception( int number, const String& description, const String& source, const char* type, const char* file, long line );
/** Copy constructor.
*/
Exception(const Exception& rhs);
/// Needed for compatibility with std::exception
~Exception() throw() {}
/** Assignment operator.
*/
void operator = (const Exception& rhs);
/** Returns a string with the full description of this error.
@remarks
The description contains the error number, the description
supplied by the thrower, what routine threw the exception,
and will also supply extra platform-specific information
where applicable. For example - in the case of a rendering
library error, the description of the error will include both
the place in which OGRE found the problem, and a text
description from the 3D rendering library, if available.
*/
virtual const String& getFullDescription(void) const;
/** Gets the error code.
*/
virtual int getNumber(void) const throw();
/** Gets the source function.
*/
virtual const String &getSource() const { return source; }
/** Gets source file name.
*/
virtual const String &getFile() const { return file; }
/** Gets line number.
*/
virtual long getLine() const { return line; }
/** Returns a string with only the 'description' field of this exception. Use
getFullDescriptionto get a full description of the error including line number,
error number and what function threw the exception.
*/
virtual const String &getDescription(void) const { return description; }
/// Override std::exception::what
const char* what() const throw() { return getFullDescription().c_str(); }
};
/** Template struct which creates a distinct type for each exception code.
@note
This is useful because it allows us to create an overloaded method
for returning different exception types by value without ambiguity.
From 'Modern C++ Design' (Alexandrescu 2001).
*/
template <int num>
struct ExceptionCodeType
{
enum { number = num };
};
// Specialised exceptions allowing each to be caught specifically
// backwards-compatible since exception codes still used
class _OgreExport UnimplementedException : public Exception
{
public:
UnimplementedException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
: Exception(inNumber, inDescription, inSource, "UnimplementedException", inFile, inLine) {}
};
class _OgreExport FileNotFoundException : public Exception
{
public:
FileNotFoundException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
: Exception(inNumber, inDescription, inSource, "FileNotFoundException", inFile, inLine) {}
};
class _OgreExport IOException : public Exception
{
public:
IOException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
: Exception(inNumber, inDescription, inSource, "IOException", inFile, inLine) {}
};
class _OgreExport InvalidStateException : public Exception
{
public:
InvalidStateException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
: Exception(inNumber, inDescription, inSource, "InvalidStateException", inFile, inLine) {}
};
class _OgreExport InvalidParametersException : public Exception
{
public:
InvalidParametersException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
: Exception(inNumber, inDescription, inSource, "InvalidParametersException", inFile, inLine) {}
};
class _OgreExport ItemIdentityException : public Exception
{
public:
ItemIdentityException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
: Exception(inNumber, inDescription, inSource, "ItemIdentityException", inFile, inLine) {}
};
class _OgreExport InternalErrorException : public Exception
{
public:
InternalErrorException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
: Exception(inNumber, inDescription, inSource, "InternalErrorException", inFile, inLine) {}
};
class _OgreExport RenderingAPIException : public Exception
{
public:
RenderingAPIException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
: Exception(inNumber, inDescription, inSource, "RenderingAPIException", inFile, inLine) {}
};
class _OgreExport RuntimeAssertionException : public Exception
{
public:
RuntimeAssertionException(int inNumber, const String& inDescription, const String& inSource, const char* inFile, long inLine)
: Exception(inNumber, inDescription, inSource, "RuntimeAssertionException", inFile, inLine) {}
};
/** Class implementing dispatch methods in order to construct by-value
exceptions of a derived type based just on an exception code.
@remarks
This nicely handles construction of derived Exceptions by value (needed
for throwing) without suffering from ambiguity - each code is turned into
a distinct type so that methods can be overloaded. This allows OGRE_EXCEPT
to stay small in implementation (desirable since it is embedded) whilst
still performing rich code-to-type mapping.
*/
class ExceptionFactory
{
private:
/// Private constructor, no construction
ExceptionFactory() {}
public:
static UnimplementedException create(
ExceptionCodeType<Exception::ERR_NOT_IMPLEMENTED> code,
const String& desc,
const String& src, const char* file, long line)
{
return UnimplementedException(code.number, desc, src, file, line);
}
static FileNotFoundException create(
ExceptionCodeType<Exception::ERR_FILE_NOT_FOUND> code,
const String& desc,
const String& src, const char* file, long line)
{
return FileNotFoundException(code.number, desc, src, file, line);
}
static IOException create(
ExceptionCodeType<Exception::ERR_CANNOT_WRITE_TO_FILE> code,
const String& desc,
const String& src, const char* file, long line)
{
return IOException(code.number, desc, src, file, line);
}
static InvalidStateException create(
ExceptionCodeType<Exception::ERR_INVALID_STATE> code,
const String& desc,
const String& src, const char* file, long line)
{
return InvalidStateException(code.number, desc, src, file, line);
}
static InvalidParametersException create(
ExceptionCodeType<Exception::ERR_INVALIDPARAMS> code,
const String& desc,
const String& src, const char* file, long line)
{
return InvalidParametersException(code.number, desc, src, file, line);
}
static ItemIdentityException create(
ExceptionCodeType<Exception::ERR_ITEM_NOT_FOUND> code,
const String& desc,
const String& src, const char* file, long line)
{
return ItemIdentityException(code.number, desc, src, file, line);
}
static ItemIdentityException create(
ExceptionCodeType<Exception::ERR_DUPLICATE_ITEM> code,
const String& desc,
const String& src, const char* file, long line)
{
return ItemIdentityException(code.number, desc, src, file, line);
}
static InternalErrorException create(
ExceptionCodeType<Exception::ERR_INTERNAL_ERROR> code,
const String& desc,
const String& src, const char* file, long line)
{
return InternalErrorException(code.number, desc, src, file, line);
}
static RenderingAPIException create(
ExceptionCodeType<Exception::ERR_RENDERINGAPI_ERROR> code,
const String& desc,
const String& src, const char* file, long line)
{
return RenderingAPIException(code.number, desc, src, file, line);
}
static RuntimeAssertionException create(
ExceptionCodeType<Exception::ERR_RT_ASSERTION_FAILED> code,
const String& desc,
const String& src, const char* file, long line)
{
return RuntimeAssertionException(code.number, desc, src, file, line);
}
};
#ifndef OGRE_EXCEPT
#define OGRE_EXCEPT(num, desc, src) throw Ogre::ExceptionFactory::create( \
Ogre::ExceptionCodeType<num>(), desc, src, __FILE__, __LINE__ );
#endif
/** @} */
/** @} */
} // Namespace Ogre
#include "OgreHeaderSuffix.h"
#endif
|