00001 00002 /* 00003 | Author: Michael Schmidt; 00004 | Gunnar Jehl 00005 | 00006 | ************************* SOFTWARE LICENSE AGREEMENT *********************** 00007 | This source code is published under the BSD License. 00008 | 00009 | See file 'LICENSE.txt' that comes with this distribution or 00010 | http://dbis.informatik.uni-freiburg.de/index.php?project=GCX/license.php 00011 | for the full license agreement. 00012 | 00013 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00014 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00015 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00016 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00017 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00018 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00019 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00020 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00021 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00022 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00023 | POSSIBILITY OF SUCH DAMAGE. 00024 | **************************************************************************** 00025 */ 00026 00035 #ifndef EXCEPTION_H 00036 #define EXCEPTION_H 00037 00038 #include <cstdlib> 00039 #include <sstream> 00040 #include <string.h> 00041 #include "typeenums.h" 00042 00044 using namespace std; 00045 00054 class Exception { 00055 00056 public: 00065 Exception(EXCEPTION_TYPE _type, const char *_error_msg, 00066 ERROR_ID _error_id = 00067 eid_notset, EXCEPTION_LEVEL _exception_level = excl_fatal); 00068 00072 virtual ~ Exception(); 00073 00080 void terminate(int exit_code = EXIT_FAILURE); 00081 00087 const char *getDebugMsg(); 00088 00094 inline const EXCEPTION_TYPE getType() { 00095 return type; 00096 } inline const char *getErrorMsg() { 00102 return error_msg; 00103 } 00104 00110 inline ERROR_ID getErrorId() { 00111 return error_id; 00112 } 00113 00119 inline const EXCEPTION_LEVEL getExceptionLevel() { 00120 return exception_level; 00121 } 00122 00123 protected: 00128 EXCEPTION_TYPE type; 00129 00134 const char *error_msg; 00135 00140 ERROR_ID error_id; 00141 00146 EXCEPTION_LEVEL exception_level; 00147 }; 00148 00149 #endif // EXCEPTION_H