[go: up one dir, main page]

Menu

[r11]: / gizmod3 / libH / Exception.hpp  Maximize  Restore  History

Download this file

112 lines (85 with data), 3.1 kB

  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
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
/**
*********************************************************************
*************************************************************************
***
*** \file Exception.cpp
*** \brief Exception class body
***
*****************************************
*****************************************
**/
/*
Copyright (c) 2006, Tim Burrell
All rights reserved.
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __Exception_h
#define __Exception_h
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <cstdlib>
#include <string>
//////////////////////////////////////////////////////////////////////////////
// Namespace
///////////////////////////////////////
namespace H {
//////////////////////////////////////////////////////////////////////////////
// Typedef, enum's
///////////////////////////////////////
/**
* \typedef ExceptionType
*
* Enum for the different Exception types
*/
typedef enum {
EXCEPTION_INFO,
EXCEPTION_WARNING,
EXCEPTION_NORMAL,
EXCEPTION_FATAL
} ExceptionType;
//////////////////////////////////////////////////////////////////////////////
// Class Definition
///////////////////////////////////////
/**
* \class Exception
* \brief Generic Exception class
*
* Generic Exception class which takes a string message as a constructor
* For throwing informative error messages
*/
class Exception : public std::exception {
public:
/// Get the type of exception
virtual const ExceptionType getExceptionType() { return mType; };
/// Get the exception's message
virtual const std::string & getExceptionMessage() { return mMessage; };
/// Get the exceptions message
virtual const char * what() { return mMessage.c_str(); };
/// Get the exceptions message
virtual const char * message() { return mMessage.c_str(); };
/// operator overload for const char * -- get the Exception's message
virtual operator const char* () const { return mMessage.c_str(); };
/// Default Constructor
Exception(const std::string & Message, ExceptionType Type = EXCEPTION_NORMAL);
/// Extended Constructor
Exception(const std::string & Message, const std::string & File, const std::string & Function, int LineNumber, ExceptionType Type = EXCEPTION_NORMAL);
/// Destructor
virtual ~Exception() throw() ;
protected:
std::string mMessage; ///< the Exception's informational message
ExceptionType mType; ///< the type of the exceptionl
};
//////////////////////////////////////////////////////////////////////////////
}
#endif // __Exception_h