DCL 4.0
Loading...
Searching...
No Matches
Exception.h
Go to the documentation of this file.
1#ifndef __DCL_EXCEPTION_H__
2#define __DCL_EXCEPTION_H__
3
4#ifndef __DCL_CONFIG_H__
5#include <dcl/Config.h>
6#endif
7
8#if __DCL_WINDOWS
9 #ifndef _WINERROR_
10 #include <WinError.h>
11 #endif
12#else
13 #include <errno.h>
14#endif
15
16#ifndef __DCL_OBJECT_H__
17#include <dcl/Object.h>
18#endif
19#ifndef __DCL_STRING_H__
20#include <dcl/String.h>
21#endif
22
23__DCL_BEGIN_NAMESPACE
24
25class DCLCAPI Exception : public Object
26{
28protected:
30
31public:
33
34 // 예외가 발생한 원인 예외 객체
35 const Exception* cause() const;
36
37 // 예외와 관련한 메시지 문자열
38 virtual String toString() const;
39
40 // 원인을 포함한 메시지
41 String toStringAll() const;
42
43 // no delete e, use e->destroy()
44 virtual void destroy();
45
46protected:
47 virtual ~Exception() {} // cannot delete e, use e->destroy()
48};
49
50inline const Exception* Exception::cause() const
51{
52 return __pCause;
53}
54
61
63{
65protected:
66 uint32_t __errorNo;
67
68#define ERROR_VALUE_MASK 0x0fffffff
69#define ERRNO_ERROR_MASK 0x00000000
70#define WINAPI_ERROR_MASK 0x10000000
71#define DCL_ERROR_MASK 0x20000000
72#define WINAPI_ERROR(n) WINAPI_ERROR_MASK | n
73#define DCL_ERROR(n) DCL_ERROR_MASK | n
74
75public:
77 SysError(uint32_t _errorNo);
78 uint32_t errorNo() const { return __errorNo; }
79 virtual String toString() const;
80};
81
82#if __DCL_WINDOWS
83 #define __EHANDLE ERROR_INVALID_HANDLE
84 #define __EPARAM ERROR_INVALID_PARAMETER
85 #define __ENOMEM ERROR_NOT_ENOUGH_MEMORY
86#else
87 #define __EHANDLE EINVAL
88 #define __EPARAM EENVAL
89 #define __ENOMEM ENOMEM
90#endif
91
93{
95public:
96 enum
97 {
98 NOMEM = __ENOMEM
99 };
100protected:
101 String __message;
102
103public:
104 IOException(const String& _name, Exception* _cause);
105 IOException(const String& _name, uint32_t _errorNo);
106 IOException(const String& _name, const String& _message);
107 virtual String toString() const;
108};
109
111{
113protected:
114 String __message;
115public:
116 InvalidIndexException(const String& _key);
117 InvalidIndexException(ssize_t _minValid, ssize_t _maxValid, size_t _errorValue);
118 virtual String toString() const;
119};
120
122{
124protected:
125 String __message;
126 size_t __sourceOffset;
127
128public:
129 ParseException(const String& _message);
130 ParseException(const String& _message, size_t _sourceOffset);
131 virtual String toString() const;
132};
133
134class DCLCAPI NumericConvertException : public ParseException
135{
136 DECLARE_CLASSINFO(NumericConvertException)
137public:
138 enum Error
139 {
140 NoError = 0,
141 InvalidNumberString,
142 Overflow,
143 Underflow
144 };
145
146 // eInvalidNumberString
147 NumericConvertException(
148 const String& _number,
149 int _radix,
150 size_t _sourceOffset
151 );
152
153 // eOverflow or eUnderflow
154 NumericConvertException(
155 Error _error,
156 const String& _number,
157 int _radix
158 );
159
160 virtual String toString() const;
161
162 Error errorCode() const { return __error; }
163
164private :
165 Error __error;
166 int __radix;
167};
168
170{
172protected:
173 String __message;
174public:
176 GenerialException(const wchar_t* _message);
177 virtual String toString() const;
178};
179
181{
183public:
184 String __expr;
185 String __message;
186 String __filename; // __FILE__
187 int __line; // __LINE__
188public:
190 const char_t* _filename,
191 unsigned int _line,
192 const char_t* _expr,
193 const char_t* _message
194 );
195
196 virtual String toString() const;
197
198 static String format(
199 const char_t* _filename,
200 unsigned int _line,
201 const char_t* _expr,
202 const char_t* _message
203 );
204};
205
206/*
207#define __DCL_CHECK_THROW(_expr, _constructor) \
208 if (_expr) throw (new _constructor)
209
210 __DCL_CHECK_THROW(_format == NULL,
211 IOException(toString(), IOException::EPARAM));
212*/
213
214/*
215class DCLCAPI SocketException : public SysCallException
216{
217 DECLARE_CLASSINFO(SocketException)
218protected:
219 String __message;
220public:
221 SocketException(const char* _message);
222 virtual String toString() const;
223};
224*/
225__DCL_END_NAMESPACE
226
227#endif // __DCL_EXCEPTION_H__
228
#define NULL
Definition Config.h:340
#define DCLCAPI
Definition Config.h:100
wchar_t char_t
Definition Config.h:275
#define __ENOMEM
Definition Exception.h:89
#define DECLARE_CLASSINFO(class_name)
Definition Object.h:210
static String format(const char_t *_filename, unsigned int _line, const char_t *_expr, const char_t *_message)
AssertError(const char_t *_filename, unsigned int _line, const char_t *_expr, const char_t *_message)
Exception(Exception *_cause=NULL)
String toStringAll() const
Definition Exception.cpp:45
const Exception * cause() const
Definition Exception.h:50
virtual ~Exception()
Definition Exception.h:47
Exception * __pCause
Definition Exception.h:29
GenerialException(Exception *_cause)
String __message
Definition Exception.h:94
IOException(const String &_name, Exception *_cause)
InvalidIndexException(const String &_key)
Object()
Definition Object.cpp:183
virtual String toString() const
Definition Object.cpp:187
virtual void destroy()
Definition Object.cpp:192
ParseException(const String &_message)
uint32_t errorNo() const
Definition Exception.h:78
SysError(Exception *_cause=NULL)