CSL 5.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

CSL_Exceptions.h
Go to the documentation of this file.
1 ///
2 /// CSL_Exceptions.h -- the CSL Exception classes (specifications + implementations)
3 ///
4 /// Exception classes
5 ///
6 /// Status - enumerated return flag type
7 /// CException - Base class of CSL exceptions (written upper-case).
8 /// MemoryError - Malloc failure subclass
9 /// Wrong kind of operand error
10 /// TimingError - Time-out
11 /// RunTimeError - Illegal operation at run time
12 /// LogicError - Impossible operation
13 /// DomainError - Numerical data of wrong type
14 /// OutOfRangeError - Data out of range
15 /// IOError - IO Error
16 ///
17 /// See the copyright notice and acknowledgment of authors in the file COPYRIGHT
18 ///
19
20 #ifndef CSL_EXCEPTIONS_H
21 #define CSL_EXCEPTIONS_H
22
23 #include <exception> // Standard C++ exception library
24 #include <string>
25
26 namespace csl {
27
28 using namespace std;
29
30 ///
31 /// CSL status flags (for return values)
32 ///
33
34 typedef enum {
35 kOk, ///< "OK" return status
36 kFound, ///< "found" return status
37 kNotFound, ///< "not found" return status
38 kEmpty, ///< "empty" return status
39 kErr ///< "error" return status
40 } Status;
41
42 #ifndef CSL_ENUMS
43 // class exception { }; // forward def needed for SWIG
44 #endif
45
46 ///
47 /// Base class of CSL exceptions (written upper-case).
48 /// Has a string message
49 ///
50
51 class CException : public std::exception {
52 public:
53 string mMessage;
54 CException(const string & msg) throw() : mMessage(msg) { };
55 ~CException() throw() { };
56 const char * what() { return mMessage.c_str(); };
57 };
58
59 ///
60 /// Malloc failure subclass
61 ///
62
63 class MemoryError : public CException {
64 public:
65 MemoryError(const string & msg) : CException(msg) { };
66 };
67
68 ///
69 /// Wrong kind of operand error
70 ///
71
72 class ValueError : public CException {
73 public:
74 ValueError(const string & msg) : CException(msg) { };
75 };
76
77 ///
78 /// Time-out
79 ///
80
81 class TimingError : public CException {
82 public:
83 TimingError(const string & msg) : CException(msg) { };
84 };
85
86 ///
87 /// Illegal operation at run time
88 ///
89
90 class RunTimeError : public CException {
91 public:
92 RunTimeError(const string & msg) : CException(msg) { };
93 };
94
95 ///
96 /// Impossible operation
97 ///
98
99 class LogicError : public CException {
100 public:
101 LogicError(const string & msg) : CException(msg) { };
102 };
103
104 ///
105 /// Numerical data of wrong type
106 ///
107
108 class DomainError : public ValueError {
109 public:
110 DomainError(const string & msg) : ValueError(msg) { };
111 };
112
113 ///
114 /// Data out of range
115 ///
116
117 class OutOfRangeError : public ValueError {
118 public:
119 OutOfRangeError(const string & msg) : ValueError(msg) { };
120 };
121
122 ///
123 /// IO Error
124 ///
125
126 class IOError : public ValueError {
127 public:
128 IOError(const string & msg) : ValueError(msg) { };
129 };
130
131 ///
132 /// DB Error
133 ///
134
135 class DBError : public LogicError {
136 public:
137 DBError(const string & msg) : LogicError(msg) { };
138 };
139
140 ///
141 /// Processing Error
142 ///
143
144 class ProcessingError : public ValueError {
145 public:
146 ProcessingError(const string & msg) : ValueError(msg) { };
147 };
148
149 }
150
151 #endif