Changeset 7367 for code/branches/doc/src/libraries/util/Exception.h
- Timestamp:
- Sep 6, 2010, 3:51:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/doc/src/libraries/util/Exception.h
r7297 r7367 31 31 @brief 32 32 Declaration of facilities to handle exceptions. 33 @details 34 Any exception thrown should inherit from orxonox::Exception. There is a macro 35 \ref CREATE_ORXONOX_EXCEPTION to create a new exception (you can find a list of 36 available exceptions in the docs of this file). <br> 37 Throwing exception is also very simple: 38 @code 39 ThrowException(General, "Something went wrong"); 40 @endcode 41 (\c General is a type of exception, see docs of this file) <br> 42 The exception will automatically contain information about file, line number 43 and function name it occurred in. <br><br> 44 There is also some magic you can do for numbers, etc.: 45 @code 46 ThrowException(General, "Error code: " << myInt << ". more info..."); 47 @endcode 48 It works with an std::ostringstream, so you can feed it all sorts of values. 33 49 */ 34 50 … … 45 61 namespace orxonox 46 62 { 47 /** 48 @brief 49 Base class for all exceptions (derived from std::exception). 63 /** Base class for all exceptions (derived from std::exception). 50 64 @details 51 65 This class provides support for information about the file, the line 52 and the function the error occured. 66 and the function the error occurred. 67 @see Exception.h 53 68 */ 54 69 class _UtilExport Exception : public std::exception … … 74 89 //! Needed for compatibility with std::exception 75 90 virtual ~Exception() throw() { } 91 //! Returns the error description 76 92 const char* what() const throw(); 77 93 78 //! Returns a full description with type, line, file and function 94 /** Returns a full description with type, line, file and function 95 @remarks 96 The composed full description gets stored to fullDescription_. But for compliance 97 with std::exception, this method has to be const. Hence fullDescription_ is declared 98 as mutable. 99 */ 79 100 virtual const std::string& getFullDescription() const; 80 101 //! Returns the string name of the exception type … … 107 128 }; 108 129 109 //! Creates a new type of exception that inherits from tracker::Exception130 //! Creates a new type of exception that inherits from orxonox::Exception 110 131 #define CREATE_ORXONOX_EXCEPTION(ExceptionName) \ 111 132 class ExceptionName##Exception : public Exception \ … … 129 150 // Creates all possible exception types. 130 151 // If you want to add a new type, simply copy and adjust a new line here. 131 #ifndef DOXYGEN_SHOULD_SKIP_THIS132 152 CREATE_ORXONOX_EXCEPTION(General); 133 153 CREATE_ORXONOX_EXCEPTION(FileNotFound); … … 142 162 CREATE_ORXONOX_EXCEPTION(NoGraphics); 143 163 CREATE_ORXONOX_EXCEPTION(AbortLoading); 144 #endif145 164 146 /** 147 @brief 148 Helper function that forwards an exception and displays the message. 165 /** Helper function that forwards an exception and displays the message. 149 166 @details 150 167 This is necessary because only when using 'throw' the objects storage is managed. … … 158 175 } 159 176 160 /** 161 @brief 162 Throws an exception and logs a message beforehand. 177 /** Throws an exception and logs a message beforehand. 163 178 @param type 164 179 Type of the exception as literal (General, Initialisation, etc.) 165 180 @param description 166 181 Exception description as string 182 @see Exception.h 167 183 */ 168 184 #define ThrowException(type, description) \
Note: See TracChangeset
for help on using the changeset viewer.