Advanced Strategic Command
errors.h
Go to the documentation of this file.
1 
5 /***************************************************************************
6  errors.h - description
7  -------------------
8  begin : Fri Oct 6 2000
9  copyright : (C) 2000 by Martin Bickel
10  email : bickel@asc-hq.org
11  ***************************************************************************/
12 
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  ***************************************************************************/
21 
22 #ifndef errors_h_included
23  #define errors_h_included
24 
25  #include "ascstring.h"
26  #include "global.h"
27  #include "misc.h"
28 
29 
30 // #ifdef HAVE_EXCEPTION
31 // #include <exception>
32 // class ASCexception : public exception { };
33  //#else
34  class ASCexception {};
35  // #endif
36 
37  class ASCmsgException : public ASCexception {
38  protected:
40  public:
41  ASCmsgException ( const ASCString& msg ) : message ( msg ) {};
42  const ASCString& getMessage ( void ) const { return message; };
43  virtual ~ASCmsgException() {};
44  };
45 
46  class InvalidID : public ASCmsgException {
47  public:
48  InvalidID ( string msg, int id ) : ASCmsgException ( "Could not find a " + msg )
49  {
50  message += " with an ID of ";
52  message += "\nThis is usually caused when the file you are trying to load uses objects "
53  "from optional data packages that you don't have installed." ;
54 
55  };
56  };
57 
58 
59  class NoMapLoaded : public ASCexception {};
60  class ShutDownMap : public ASCexception {};
61  class OutOfRange : public ASCexception {};
62 
63 
65  public:
66  AssertionException ( const ASCString& check, const ASCString& file, int line ) : ASCmsgException ( ASCString("Assertion failed: ") + check + " at " + file + ":" + ASCString::toString(line) ) {};
67  };
68 
69 #define assertOrThrow(expr) (static_cast<void> ( (expr) ? 0 : (throw AssertionException (#expr, __FILE__, __LINE__))))
70 
71 
72 
73 #endif
ASCString message
Definition: errors.h:39
miscellaneous functions which are used by ASC and all its tools
Global platform dependant definitions. This file just branches to the platform specific files in thei...
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
static ASCString toString(int i)
converts the parameter to a String
Definition: ascstring.cpp:193
ASCmsgException(const ASCString &msg)
Definition: errors.h:41
const ASCString & getMessage(void) const
Definition: errors.h:42
InvalidID(string msg, int id)
Definition: errors.h:48
AssertionException(const ASCString &check, const ASCString &file, int line)
Definition: errors.h:66
virtual ~ASCmsgException()
Definition: errors.h:43
void line(int x1, int y1, int x2, int y2, Uint8 actcol)
draws a simple line on the screen. Not very fast...
Definition: basegfx.cpp:181