1 |
|
2 |
/* $Id$ */ |
3 |
|
4 |
/******************************************************* |
5 |
* |
6 |
* Copyright 2003-2007 by ACceSS MNRF |
7 |
* Copyright 2007 by University of Queensland |
8 |
* |
9 |
* http://esscc.uq.edu.au |
10 |
* Primary Business: Queensland, Australia |
11 |
* Licensed under the Open Software License version 3.0 |
12 |
* http://www.opensource.org/licenses/osl-3.0.php |
13 |
* |
14 |
*******************************************************/ |
15 |
|
16 |
#ifndef ESYSEXCEPTION_H |
17 |
#define ESYSEXCEPTION_H |
18 |
#include "system_dep.h" |
19 |
|
20 |
#include <string> |
21 |
#include <sstream> |
22 |
#include <exception> |
23 |
#include <algorithm> |
24 |
|
25 |
namespace esysUtils { |
26 |
/** |
27 |
\page esys_exception Esys Exceptions |
28 |
A base class for exception classes used within Esys system. |
29 |
|
30 |
\version 1.0.0 |
31 |
|
32 |
\section class_desc Class Description: |
33 |
A base class for exception classes used within Esys system. |
34 |
|
35 |
\section class_limits Class Limitations: |
36 |
None |
37 |
|
38 |
\section class_conds Class Conditions of Use: |
39 |
None |
40 |
|
41 |
\section throws Throws: |
42 |
None |
43 |
|
44 |
*/ |
45 |
class EsysException:public std::exception { |
46 |
public: |
47 |
/** |
48 |
\brief |
49 |
Default Constructor. Creates an exception with no message. |
50 |
*/ |
51 |
EsysException(); |
52 |
/** |
53 |
* \brief |
54 |
Constructor which creates a EsysException with the given message |
55 |
|
56 |
@param exceptionReason Input - Exception message. |
57 |
*/ |
58 |
EsysException(const std::string &exceptionReason); |
59 |
/** |
60 |
* \brief |
61 |
Constructor which creates a EsysException with the given message |
62 |
|
63 |
@param cStr - Exception message. |
64 |
*/ |
65 |
EsysException( const char *cStr ); |
66 |
/** |
67 |
* \brief |
68 |
Copy constructor |
69 |
|
70 |
@param inException Input - EsysException |
71 |
*/ |
72 |
EsysException(const EsysException &inException); |
73 |
/// Destructor |
74 |
virtual ~EsysException() throw(); |
75 |
/** |
76 |
\brief |
77 |
Assignment operator. |
78 |
|
79 |
@param inException Input - Exception to be copied. |
80 |
*/ |
81 |
EsysException &operator=(const EsysException &inException); |
82 |
/** |
83 |
\brief |
84 |
Return the exception message in the form |
85 |
<Exception Name>: <Exception Message> |
86 |
|
87 |
@return the exception message. |
88 |
*/ |
89 |
std::string toString() const; |
90 |
/** |
91 |
\brief |
92 |
Return the name of the exception. This is expected to be overloaded |
93 |
in derived classes with the derived class name. |
94 |
|
95 |
@return the name of the exception. |
96 |
*/ |
97 |
virtual std::string exceptionName() const; |
98 |
/** |
99 |
\brief |
100 |
Return the ostrstream that contains the exception message. |
101 |
This is useful for entering or adding to the message as the stream |
102 |
insertion operators can then be used. |
103 |
|
104 |
@return the ostrstream for the exception reason. |
105 |
*/ |
106 |
std::ostringstream& reason(); |
107 |
/** |
108 |
\brief |
109 |
Return a description of the exception in the same format as the toString |
110 |
method. |
111 |
|
112 |
@return a description of the exception. |
113 |
*/ |
114 |
virtual const char* what() const throw(); |
115 |
private: |
116 |
// |
117 |
// the exception message |
118 |
std::ostringstream m_reason; |
119 |
// |
120 |
// the full exception message kept in permenant storage |
121 |
mutable std::string m_exceptionMessage; |
122 |
}; |
123 |
/** |
124 |
\brief |
125 |
Stream insertion operator for EsysExceptions |
126 |
|
127 |
@param output Input - Output stream. |
128 |
@param inException Input - The exception to be inserted into the output |
129 |
stream. |
130 |
*/ |
131 |
std::ostream &operator<<(std::ostream &output, EsysException &inException); |
132 |
|
133 |
} |
134 |
|
135 |
#endif |