Orxonox
0.0.5 Codename: Arcturus
|
Declaration of facilities to handle exceptions.More...
#include "UtilPrereqs.h"
#include <exception>
#include <sstream>
#include <string>
#include "Output.h"
Go to the source code of this file.
Classes | |
class | orxonox::Exception |
Base class for all exceptions (derived from std::exception). More... | |
Namespaces | |
orxonox | |
Die Wagnis Klasse hat die folgenden Aufgaben: | |
Macros | |
#define | CREATE_ORXONOX_EXCEPTION(ExceptionName) |
Creates a new type of exception that inherits from orxonox::Exception. More... | |
#define | ThrowException(type, description) throw orxonox::exceptionThrowerHelper(type##Exception(static_cast<std::ostringstream&>(std::ostringstream().flush() << description).str(), __LINE__, __FILE__, __FUNCTIONNAME__)) |
Throws an exception and logs a message beforehand. More... | |
Functions | |
orxonox::CREATE_ORXONOX_EXCEPTION (General) | |
orxonox::CREATE_ORXONOX_EXCEPTION (FileNotFound) | |
orxonox::CREATE_ORXONOX_EXCEPTION (Argument) | |
orxonox::CREATE_ORXONOX_EXCEPTION (PhysicsViolation) | |
orxonox::CREATE_ORXONOX_EXCEPTION (ParseError) | |
orxonox::CREATE_ORXONOX_EXCEPTION (PluginsNotFound) | |
orxonox::CREATE_ORXONOX_EXCEPTION (InitialisationFailed) | |
orxonox::CREATE_ORXONOX_EXCEPTION (InitialisationAborted) | |
orxonox::CREATE_ORXONOX_EXCEPTION (NotImplemented) | |
orxonox::CREATE_ORXONOX_EXCEPTION (GameState) | |
orxonox::CREATE_ORXONOX_EXCEPTION (NoGraphics) | |
orxonox::CREATE_ORXONOX_EXCEPTION (AbortLoading) | |
template<class T > | |
const T & | orxonox::exceptionThrowerHelper (const T &exception) |
Helper function that forwards an exception and displays the message. More... | |
Declaration of facilities to handle exceptions.
Any exception thrown should inherit from orxonox::Exception. There is a macro CREATE_ORXONOX_EXCEPTION to create a new exception (you can find a list of available exceptions in the docs of this file).
Throwing exception is also very simple:
(General
is a type of exception, see docs of this file)
The exception will automatically contain information about file, line number and function name it occurred in.
There is also some magic you can do for numbers, etc.:
It works with an std::ostringstream, so you can feed it all sorts of values.
#define CREATE_ORXONOX_EXCEPTION | ( | ExceptionName | ) |
Creates a new type of exception that inherits from orxonox::Exception.
#define ThrowException | ( | type, | |
description | |||
) | throw orxonox::exceptionThrowerHelper(type##Exception(static_cast<std::ostringstream&>(std::ostringstream().flush() << description).str(), __LINE__, __FILE__, __FUNCTIONNAME__)) |
Throws an exception and logs a message beforehand.
type | Type of the exception as literal (General, Initialisation, etc.) |
description | Exception description as string |