1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
/** \file errors.h
\brief The (base-) classes which are thrown as exceptions
*/
/***************************************************************************
errors.h - description
-------------------
begin : Fri Oct 6 2000
copyright : (C) 2000 by Martin Bickel
email : bickel@asc-hq.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef errors_h_included
#define errors_h_included
#include "ascstring.h"
#include "global.h"
#include "misc.h"
// #ifdef HAVE_EXCEPTION
// #include <exception>
// class ASCexception : public exception { };
//#else
class ASCexception {};
// #endif
class ASCmsgException : public ASCexception {
protected:
ASCString message;
public:
ASCmsgException ( const ASCString& msg ) : message ( msg ) {};
const ASCString& getMessage ( void ) const { return message; };
virtual ~ASCmsgException() {};
};
class InvalidID : public ASCmsgException {
public:
InvalidID ( string msg, int id ) : ASCmsgException ( "Could not find a " + msg )
{
message += " with an ID of ";
message += ASCString::toString( id );
message += "\nThis is usually caused when the file you are trying to load uses objects "
"from optional data packages that you don't have installed." ;
};
};
class NoMapLoaded : public ASCexception {};
class ShutDownMap : public ASCexception {};
class OutOfRange : public ASCexception {};
class AssertionException : public ASCmsgException {
public:
AssertionException ( const ASCString& check, const ASCString& file, int line ) : ASCmsgException ( ASCString("Assertion failed: ") + check + " at " + file + ":" + ASCString::toString(line) ) {};
};
#define assertOrThrow(expr) (static_cast<void> ( (expr) ? 0 : (throw AssertionException (#expr, __FILE__, __LINE__))))
#endif
|