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