|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * CException - Generic exception handler. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @released |
|
23 @internalTechnology |
|
24 */ |
|
25 |
|
26 #ifndef EXCEPTION_H |
|
27 #define EXCEPTION_H |
|
28 #include "toolsconf.h" |
|
29 #include <string> |
|
30 |
|
31 namespace ExceptionCodes |
|
32 { |
|
33 enum TExceptionCode |
|
34 { |
|
35 EUnintializedCode = -1, |
|
36 ENone, |
|
37 EEnvNotSpecified, |
|
38 |
|
39 // options exception |
|
40 EInvalidArgument=10, |
|
41 EMandatoryOption, |
|
42 EMutuallyExclusive, |
|
43 EFileNotPresent, |
|
44 EFileExists, |
|
45 |
|
46 // xml exceptions |
|
47 EWarning=20, |
|
48 EError, |
|
49 EFatalError, |
|
50 EParseError, |
|
51 EResetError, |
|
52 |
|
53 // database exceptions |
|
54 ELibraryLoadError=30, |
|
55 ESqlArgumentError, |
|
56 ESqlNotFoundError, |
|
57 ESqlCorrupt, |
|
58 |
|
59 // general exceptions |
|
60 EConversionError=40, |
|
61 }; |
|
62 } |
|
63 |
|
64 class CException |
|
65 { |
|
66 public: |
|
67 |
|
68 /** |
|
69 constructs the exception handler object through setting the message and the |
|
70 corresponding code is uninitialized. |
|
71 */ |
|
72 DllExport CException(const std::string& aMessage); |
|
73 |
|
74 /** |
|
75 constructs the exception handler object through setting the code and the |
|
76 corresponding message is empty. |
|
77 */ |
|
78 DllExport CException(int aCode); |
|
79 |
|
80 /** |
|
81 constructs the exception handler object through setting the message and the |
|
82 corresponding code. |
|
83 */ |
|
84 DllExport CException(const std::string& aMessage, int aCode); |
|
85 |
|
86 /** |
|
87 constructs the exception handler object through setting the message and the |
|
88 corresponding code. |
|
89 */ |
|
90 DllExport CException(const char* aMessage, int aCode); |
|
91 |
|
92 /** |
|
93 Retrieve the message corresponding to the exception handler. |
|
94 */ |
|
95 DllExport const std::string& GetMessageA() const; |
|
96 |
|
97 /** |
|
98 Retrieve the code corresponding to the exception handler. |
|
99 */ |
|
100 DllExport int GetCode() const; |
|
101 |
|
102 protected: |
|
103 std::string iMessage; |
|
104 int iCode; |
|
105 |
|
106 protected: |
|
107 static std::string EmptyMessage; |
|
108 |
|
109 }; |
|
110 |
|
111 #endif // EXCEPTION_H |