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