00001 00005 /*************************************************************************** 00006 errors.h - description 00007 ------------------- 00008 begin : Fri Oct 6 2000 00009 copyright : (C) 2000 by Martin Bickel 00010 email : bickel@asc-hq.org 00011 ***************************************************************************/ 00012 00013 /*************************************************************************** 00014 * * 00015 * This program is free software; you can redistribute it and/or modify * 00016 * it under the terms of the GNU General Public License as published by * 00017 * the Free Software Foundation; either version 2 of the License, or * 00018 * (at your option) any later version. * 00019 * * 00020 ***************************************************************************/ 00021 00022 #ifndef errors_h_included 00023 #define errors_h_included 00024 00025 #include "ascstring.h" 00026 #include "global.h" 00027 #include "misc.h" 00028 00029 00030 #ifdef HAVE_EXCEPTION 00031 #include <exception> 00032 class ASCexception : public exception { }; 00033 #else 00034 class ASCexception {}; 00035 #endif 00036 00037 class ASCmsgException : public ASCexception { 00038 protected: 00039 ASCString message; 00040 public: 00041 ASCmsgException ( const ASCString& msg ) : message ( msg ) {}; 00042 const ASCString& getMessage ( void ) const { return message; }; 00043 virtual ~ASCmsgException() {}; 00044 }; 00045 00046 class InvalidID : public ASCmsgException { 00047 public: 00048 InvalidID ( string msg, int id ) : ASCmsgException ( "Could not find a " + msg ) 00049 { 00050 message += " with an ID of "; 00051 message += ASCString::toString( id ); 00052 message += "\nThis is usually caused when the file you are trying to load uses objects " 00053 "from optional data packages that you don't have installed." ; 00054 00055 }; 00056 }; 00057 00058 00059 class NoMapLoaded : public ASCexception {}; 00060 class ShutDownMap : public ASCexception {}; 00061 class OutOfRange : public ASCexception {}; 00062 00063 00064 class AssertionException : public ASCmsgException { 00065 public: 00066 AssertionException ( const ASCString& check, const ASCString& file, int line ) : ASCmsgException ( ASCString("Assertion failed: ") + check + " at " + file + ":" + ASCString::toString(line) ) {}; 00067 }; 00068 00069 #define assertOrThrow(expr) (static_cast<void> ( (expr) ? 0 : (throw AssertionException (#expr, __FILE__, __LINE__)))) 00070 00071 00072 00073 #endif
1.4.2