GException.cpp
2.01 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
/***************************************************************************
* GException.cpp - exception handler *
* ----------------------------------------------------------------------- *
* copyright : (C) 2006 by Jurgen Knodlseder *
* ----------------------------------------------------------------------- *
* *
* 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. *
* *
***************************************************************************/
/* __ Includes ___________________________________________________________ */
#include "GException.hpp"
#include <string> // string
#include <sstream> // ostringstream
using namespace std;
/***************************************************************************
* Exception handler base class definition *
***************************************************************************/
const char* GException::what() const throw()
{
string message = "*** ERROR in " + m_origin + ": " + m_message;
return message.c_str();
}
/***************************************************************************
* Specific exception class definitions *
***************************************************************************/
mem_alloc::mem_alloc(string origin, unsigned num)
{
ostringstream s_num;
s_num << num;
m_origin = origin;
m_message = "Memory allocation error (" + s_num.str() + " elements)";
}
empty::empty(string origin)
{
m_origin = origin;
m_message = "Zero-size allocation";
}