1 | /*------------------------------------------------------------------------------ |
2 | * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team |
3 | * |
4 | * Distributable under the terms of either the Apache License (Version 2.0) or |
5 | * the GNU Lesser General Public License, as specified in the COPYING file. |
6 | ------------------------------------------------------------------------------*/ |
7 | #ifndef _lucene_debug_error_ |
8 | #define _lucene_debug_error_ |
9 | |
10 | #if defined(_LUCENE_PRAGMA_ONCE) |
11 | # pragma once |
12 | #endif |
13 | |
14 | #define CL_ERR_UNKNOWN -1 |
15 | #define CL_ERR_IO 1 |
16 | #define CL_ERR_NullPointer 2 |
17 | #define CL_ERR_Runtime 3 |
18 | #define CL_ERR_IllegalArgument 4 |
19 | #define CL_ERR_Parse 5 |
20 | #define CL_ERR_TokenMgr 6 |
21 | #define CL_ERR_UnsupportedOperation 7 |
22 | #define CL_ERR_InvalidState 8 |
23 | #define CL_ERR_IndexOutOfBounds 9 |
24 | #define CL_ERR_TooManyClauses 10 |
25 | #define CL_ERR_RAMTransaction 11 |
26 | #define CL_ERR_InvalidCast 12 |
27 | #define CL_ERR_IllegalState 13 |
28 | |
29 | |
30 | |
31 | //////////////////////////////////////////////////////// |
32 | //error try/throw/catch definitions |
33 | //////////////////////////////////////////////////////// |
34 | #ifdef _CL_DISABLE_NATIVE_EXCEPTIONS |
35 | /*#define try _jpr_Try |
36 | #define _CLCATCH _jpr_Catch |
37 | #define _CLFINALLY(x) xxxx |
38 | #define _CLTHROWA(y) _jpr_Throw |
39 | #define _THROWA_DEL(y) _jpr_Throw |
40 | #define _RETHROW(x) _jpr_Throw |
41 | #define _CLTHROWT(y) _jpr_Throw |
42 | |
43 | #define _THROWS ,_jpr_Throws*/ |
44 | #else |
45 | class CLuceneError |
46 | { |
47 | int error_number; |
48 | char* _awhat; |
49 | TCHAR* _twhat; |
50 | public: |
51 | CLuceneError(const CLuceneError& clone); |
52 | CLuceneError(int num, const char* str, bool ownstr); |
53 | #ifdef _UCS2 |
54 | CLuceneError(int num, const TCHAR* str, bool ownstr); |
55 | #endif |
56 | int number(){return error_number;} |
57 | char* what(); |
58 | TCHAR* twhat(); |
59 | ~CLuceneError() throw(); |
60 | }; |
61 | |
62 | //#define _THROWS //does nothing |
63 | #define _CLFINALLY(x) catch(...){ x; throw; } x //note: code x is not run if return is called |
64 | #define _CLTHROWA(number, str) throw CLuceneError(number, str,false) |
65 | #define _CLTHROWT(number, str) throw CLuceneError(number, str,false) |
66 | #define _CLTHROWA_DEL(number, str) throw CLuceneError(number, str,true) //throw a string ensures the value is deleted |
67 | #define _CLTHROWT_DEL(number, str) throw CLuceneError(number, str,true) //throw a string ensures the value is deleted |
68 | |
69 | |
70 | #endif //_LUCENE_DISABLE_EXCEPTIONS |
71 | // |
72 | //////////////////////////////////////////////////////// |
73 | |
74 | #endif |
75 | |