1 |
dpavlin |
1 |
/* |
2 |
|
|
* HT Editor |
3 |
|
|
* except.h |
4 |
|
|
* |
5 |
|
|
* Copyright (C) 1999-2002 Stefan Weyergraf |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License version 2 as |
9 |
|
|
* published by the Free Software Foundation. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#ifndef __EXCEPT_H__ |
22 |
|
|
#define __EXCEPT_H__ |
23 |
|
|
|
24 |
|
|
#include <errno.h> // for IOException |
25 |
|
|
|
26 |
|
|
#include "tools/data.h" |
27 |
|
|
#include "tools/str.h" |
28 |
|
|
|
29 |
|
|
/** |
30 |
|
|
* A exception. |
31 |
|
|
*/ |
32 |
|
|
class Exception { |
33 |
|
|
public: |
34 |
|
|
Exception() throw(); |
35 |
|
|
virtual ~Exception(); |
36 |
|
|
/* new */ |
37 |
|
|
virtual String & reason(String &result) const; |
38 |
|
|
}; |
39 |
|
|
|
40 |
|
|
#define MSG_EXCEPTION_MAX_ERRSTR 256 |
41 |
|
|
|
42 |
|
|
/** |
43 |
|
|
* A described exception. |
44 |
|
|
*/ |
45 |
|
|
class MsgException: public Exception { |
46 |
|
|
protected: |
47 |
|
|
char estr[MSG_EXCEPTION_MAX_ERRSTR]; |
48 |
|
|
public: |
49 |
|
|
MsgException(const char *errstr) throw(); |
50 |
|
|
MsgException() throw(); |
51 |
|
|
/* new */ |
52 |
|
|
virtual String &reason(String &result) const; |
53 |
|
|
}; |
54 |
|
|
|
55 |
|
|
/** |
56 |
|
|
* A formatted described exception. |
57 |
|
|
*/ |
58 |
|
|
class MsgfException: public MsgException { |
59 |
|
|
public: |
60 |
|
|
MsgfException(const char *errstr, ...) throw(); |
61 |
|
|
}; |
62 |
|
|
|
63 |
|
|
/** |
64 |
|
|
* A I/O exception. |
65 |
|
|
*/ |
66 |
|
|
class IOException: public Exception { |
67 |
|
|
protected: |
68 |
|
|
String errstr; |
69 |
|
|
public: |
70 |
|
|
int mPosixErrno; |
71 |
|
|
|
72 |
|
|
IOException(int aPosixErrno) throw(); |
73 |
|
|
virtual ~IOException(); |
74 |
|
|
/* new */ |
75 |
|
|
virtual String &reason(String &result) const; |
76 |
|
|
}; |
77 |
|
|
|
78 |
|
|
class InternalException: public Exception { |
79 |
|
|
public: |
80 |
|
|
}; |
81 |
|
|
|
82 |
|
|
/** |
83 |
|
|
* A exception, indicating a not-implemented function. |
84 |
|
|
*/ |
85 |
|
|
class NotImplementedException: public InternalException { |
86 |
|
|
protected: |
87 |
|
|
String location; |
88 |
|
|
public: |
89 |
|
|
NotImplementedException(const String &filename, int line_number) throw(); |
90 |
|
|
/* new */ |
91 |
|
|
virtual String &reason(String &result) const; |
92 |
|
|
}; |
93 |
|
|
|
94 |
|
|
/** |
95 |
|
|
* A exception, indicating a illegal argument. |
96 |
|
|
*/ |
97 |
|
|
class IllegalArgumentException: public InternalException { |
98 |
|
|
protected: |
99 |
|
|
String location; |
100 |
|
|
public: |
101 |
|
|
IllegalArgumentException(const String &filename, int line_number) throw(); |
102 |
|
|
/* new */ |
103 |
|
|
virtual String &reason(String &result) const; |
104 |
|
|
}; |
105 |
|
|
|
106 |
|
|
/** |
107 |
|
|
* A exception, indicating a illegal type-cast. |
108 |
|
|
*/ |
109 |
|
|
class TypeCastException: public InternalException { |
110 |
|
|
protected: |
111 |
|
|
String aresult; |
112 |
|
|
public: |
113 |
|
|
TypeCastException(const String &cast_type, const String &obj_type) throw(); |
114 |
|
|
/* new */ |
115 |
|
|
virtual String &reason(String &result) const; |
116 |
|
|
}; |
117 |
|
|
|
118 |
|
|
#endif /* __EXCEPT_H__ */ |
119 |
|
|
|