|
1 /* |
|
2 * Copyright (c) 2007 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 "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: bad alloc eception interface |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef ALFEXCEPTION_H_ |
|
22 #define ALFEXCEPTION_H_ |
|
23 |
|
24 #include <osn/osncommon.h> |
|
25 #include <stdexcept> |
|
26 |
|
27 using namespace std; |
|
28 |
|
29 namespace osncore |
|
30 { |
|
31 |
|
32 #define STRINGIFY(x) #x |
|
33 #define TOSTRING(x) STRINGIFY(x) |
|
34 |
|
35 #ifdef ALF_DEBUG_EXCEPTIONS |
|
36 /** |
|
37 * Use this macro for throwing exceptions in the widgetmodel code. |
|
38 * |
|
39 * @param p1 Exception class |
|
40 * @param p2 Error code |
|
41 * @param p3 Debug information string |
|
42 */ |
|
43 #define ALF_THROW(p1,p2,p3) \ |
|
44 {p1 p4= p1(p2,p3, __FILE__ ":" TOSTRING(__LINE__)); throw (p4);} |
|
45 #else |
|
46 #define ALF_THROW(p1,p2,p3) {p1 p4= p1(p2); throw(p4);} |
|
47 #endif // ALF_DEBUG_EXCEPTIONS |
|
48 |
|
49 |
|
50 /** |
|
51 * Error codes for Alf Widget Model. These error codes are sent within |
|
52 * AlfException class and they are common across all widgets. Widget specific |
|
53 * exceptions are defined together with widget specific exception classes. |
|
54 * For more information on widget specific errors see widget specific exception |
|
55 * classes (like CAlfButtonException). |
|
56 */ |
|
57 enum AlfWidgetModelException |
|
58 { |
|
59 ECommonError, |
|
60 |
|
61 /** Passed attribute had no meaning in the object |
|
62 where it was passed to. */ |
|
63 EInvalidAttribute, |
|
64 |
|
65 /* Passed attribute was valid, but the value for the |
|
66 attribute was invalid. */ |
|
67 EInvalidAttributeValue, |
|
68 |
|
69 /** Not enought information provided to affect the specified attribute. */ |
|
70 EIncompleteAttributeValues, |
|
71 |
|
72 /** Passed visual was invalid */ |
|
73 EInvalidVisual, |
|
74 |
|
75 /** Creation of visual failed */ |
|
76 ECanNotCreateVisual, |
|
77 |
|
78 /** Passed visual value was invalid */ |
|
79 EInvalidVisualValue, |
|
80 |
|
81 /** Passed Element was invalid */ |
|
82 EInvalidElement, |
|
83 |
|
84 /** Invalid data type in Alf::IAlfVariantType */ |
|
85 EInvalidVariantDataType, |
|
86 |
|
87 /** Array Index out of bounds */ |
|
88 EInvalidArrayIndex, |
|
89 |
|
90 /** A non-applicable operation was performed on a |
|
91 Alf::IAlfContainer object. */ |
|
92 EInvalidContainerOperation, |
|
93 |
|
94 /** A non-applicable operation was performed on a |
|
95 Alf::IAlfMap object. */ |
|
96 EInvalidMapOperation, |
|
97 |
|
98 /** A non-applicable operation was performed on a |
|
99 Alf::IAlfBranch object. */ |
|
100 EInvalidBranchOperation, |
|
101 |
|
102 /** An invalid operation was perfomed on a |
|
103 Alf::IAlfModel object. */ |
|
104 EInvalidModelOperation, |
|
105 |
|
106 /** Passed Widget was invalid */ |
|
107 EInvalidWidget, |
|
108 |
|
109 /** |
|
110 * An invalid instance ID was supplied to the factory while creating a |
|
111 * widget. Also used if an attempt is used to create a widget with same |
|
112 * instance ID as an existing widget. |
|
113 */ |
|
114 EInvalidWidgetInstanceId, |
|
115 |
|
116 /** |
|
117 * No display was found from the UI Accelerator Toolkit environment in |
|
118 * which the widget should have been constructed. |
|
119 * See Alf::IAlfWidgetFactory::createWidget() for more information. |
|
120 */ |
|
121 EDisplayNotFound, |
|
122 |
|
123 /** |
|
124 * EInvalidArgument error code can be used when a user passes an |
|
125 * argument which is invalid. For example, user tries to set alignment |
|
126 * of vertical scrollbar as top or bottom (vertical scrollbar can be left or |
|
127 * right aligned only). |
|
128 */ |
|
129 EInvalidArgument, |
|
130 |
|
131 /** |
|
132 * Error code used when an operation would result in an invalid object |
|
133 * hierarchy. There are multiple object hierarchies maintained in widget |
|
134 * model that this error code can relate to. Widget objects are stored in a |
|
135 * hierarchy under a view widget |
|
136 * (see Alf::IAlfContainerWidget and Alf::IAlfWidget for more information). |
|
137 * Widget presentation can be constructed from a hierarchy of visual |
|
138 * templates (see Alf::IAlfVisualTemplate). |
|
139 */ |
|
140 EInvalidHierarchy |
|
141 }; |
|
142 |
|
143 /** |
|
144 * @class AlfException alfexception.h "alf/alfexception.h" |
|
145 * Base exception class. |
|
146 * |
|
147 * Exceptions specify an error code, which can be one of the error codes |
|
148 * defined in osncore::AlfWidgetModelException. Concrete widgets derive their |
|
149 * own exception classes from this base class. If the exception is thrown from |
|
150 * a concrete widget, the error code can also be one of the widget specific |
|
151 * error codes. |
|
152 * |
|
153 * @lib alfwidgetutils.lib |
|
154 * @since S60 ?S60_version |
|
155 * @status Draft |
|
156 */ |
|
157 class AlfException : public exception |
|
158 { |
|
159 public: |
|
160 /** |
|
161 * Constructor. |
|
162 * @param aErrorCode Error code |
|
163 */ |
|
164 OSN_IMPORT AlfException( const int aErrorCode ) throw(); |
|
165 |
|
166 /** |
|
167 * Constructor. |
|
168 * @param aErrorCode Error code |
|
169 * @param aInfo Optional additional information or NULL |
|
170 */ |
|
171 OSN_IMPORT AlfException( int aErrorCode, const char* aInfo ) throw(); |
|
172 |
|
173 /** |
|
174 * Constructor. |
|
175 * @param aErrorCode Error code |
|
176 * @param aInfo Optional additional information or NULL |
|
177 * @param aFileAndLine Optional file and line information or NULL |
|
178 */ |
|
179 OSN_IMPORT AlfException( |
|
180 int aErrorCode, const char* aInfo, const char* aFileAndLine ) throw(); |
|
181 |
|
182 /** |
|
183 * Class Destructor. |
|
184 */ |
|
185 OSN_IMPORT virtual ~AlfException() throw(); |
|
186 |
|
187 /** |
|
188 * Returns the description of the exception. |
|
189 * @return The description of the exception. |
|
190 */ |
|
191 OSN_IMPORT virtual const char* what() const throw(); |
|
192 |
|
193 /** |
|
194 * Returns the error code of the exception. |
|
195 * @return The error code of the exception. |
|
196 */ |
|
197 OSN_IMPORT virtual int errorCode() const throw(); |
|
198 |
|
199 /** |
|
200 * Returns additional information defined in the exception. |
|
201 * This can be e.g. the name of the class, which has thrown the exception. |
|
202 * |
|
203 * @return Additional information defined in the exception. |
|
204 */ |
|
205 OSN_IMPORT virtual const char* info() const throw(); |
|
206 |
|
207 /** |
|
208 * Returns a string with the filename and the line number of the source code, |
|
209 * which has thrown the exception. If the information does not exist, |
|
210 * an empty string is returned. |
|
211 * |
|
212 * @return A string with the filename and the line number of the source code, |
|
213 * which has thrown the exception. |
|
214 */ |
|
215 OSN_IMPORT const char* fileAndLine() const throw(); |
|
216 |
|
217 private: // data |
|
218 |
|
219 int mErrorCode; |
|
220 const char* mInfo; |
|
221 const char* mFileAndLine; |
|
222 }; |
|
223 |
|
224 } |
|
225 |
|
226 #endif |