ESScript
Revision_
Main Page
Namespaces
Classes
Files
File List
File Members
esysUtils
src
EsysException.h
Go to the documentation of this file.
1
2
/*****************************************************************************
3
*
4
* Copyright (c) 2003-2013 by University of Queensland
5
* http://www.uq.edu.au
6
*
7
* Primary Business: Queensland, Australia
8
* Licensed under the Open Software License version 3.0
9
* http://www.opensource.org/licenses/osl-3.0.php
10
*
11
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12
* Development since 2012 by School of Earth Sciences
13
*
14
*****************************************************************************/
15
16
17
#ifndef ESYSEXCEPTION_H
18
#define ESYSEXCEPTION_H
19
#include "
system_dep.h
"
20
21
#include <string>
22
#include <exception>
23
#include <iostream>
24
25
namespace
esysUtils
26
{
30
class
EsysException
:
public
std::exception
31
{
32
33
protected
:
34
35
typedef
std::exception
Parent
;
36
37
38
public
:
43
ESYSUTILS_DLL_API
44
EsysException
();
45
52
ESYSUTILS_DLL_API
53
EsysException
(
const
std::string &exceptionReason);
54
61
ESYSUTILS_DLL_API
62
EsysException
(
const
char
*cStr );
63
70
ESYSUTILS_DLL_API
71
EsysException
(
const
EsysException
&other);
72
74
ESYSUTILS_DLL_API
75
virtual
~EsysException
()
THROW
(
NO_ARG
);
76
86
ESYSUTILS_DLL_API
87
EsysException
&
88
operator=(const
EsysException
&other)
THROW
(NO_ARG);
89
97
inline
98
const std::
string
&
toString
() const;
99
107
ESYSUTILS_DLL_API
108
virtual const std::
string
&
exceptionName
() const;
109
116
inline
117
const std::
string
&
reason
() const;
118
125
inline
126
void
setReason
(const std::
string
&new_reason);
127
135
ESYSUTILS_DLL_API
136
inline
137
virtual const
char
*
what
() const
THROW
(NO_ARG);
138
139
144
inline
145
void
updateMessage
();
146
147
148
private:
149
//
150
// the exception reason
151
std::
string
m_reason
;
152
153
//
154
// the full exception message
155
std::
string
m_exceptionMessage
;
156
157
//
158
// the exception name is immutable and class-wide.
159
// Inheritor note; you need one of these too.
160
// and an overloaded exceptionName() in your .cpp implementation file.
161
static const std::
string
exceptionNameValue
;
162
163
};
164
173
ESYSUTILS_DLL_API
174
std::ostream &operator<<(std::ostream &output,
EsysException
&inException);
175
176
178
179
const std::
string
&
EsysException
::
reason
()
const
180
{
181
return
m_reason
;
182
}
183
184
// return the message as a std::string
185
const
std::string &
EsysException::toString
()
const
186
{
187
return
m_exceptionMessage
;
188
}
189
190
void
EsysException::setReason
(
const
std::string &new_reason)
191
{
192
m_reason
= new_reason;
193
updateMessage
();
194
}
195
196
const
char
*
EsysException::what
() const
THROW
(
NO_ARG
)
197
{
198
return
m_exceptionMessage
.c_str();
199
}
200
201
void
EsysException::updateMessage
()
202
{
203
m_exceptionMessage
=
exceptionName
() +
": "
+
m_reason
;
204
}
205
206
}
207
208
#endif
Generated on Thu Dec 12 2013 03:47:17 for ESScript by
1.8.1.2