2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FBaseResult.cpp
19 * @brief This is the implementation file of Result class.
22 #include <FBaseResult.h>
23 #include <FBaseErrorDefine.h>
25 #define ARR_ITEM_COUNT(arr) (sizeof(arr) / sizeof(arr[0]))
26 #define ERR_TABLE_INITIALIZER(no) {(ERR_SRC_FRAMEWORK + SET_E_CAUSE(no)), \
27 ((ERR_SRC_FRAMEWORK + SET_E_CAUSE(no)) + ARR_ITEM_COUNT(__errTable ## no) - 1), __errTable ## no}
36 static __thread result lastResult = E_SUCCESS;
38 static const char* E_SUCCESS_STRING = "E_SUCCESS";
39 static const char* E_FAILURE_STRING = "E_FAILURE";
42 __BinarySearchErrorTable(ErrTableType errTable[], result value, int low, int high)
47 int mid = low + (high - low) / 2;
48 result rbegin = errTable[mid].rbegin;
49 result rend = errTable[mid].rend;
55 else if (value > rend)
61 return errTable[mid].table[value - rbegin];
64 if (value == E_SUCCESS)
66 return E_SUCCESS_STRING;
68 else if (value == E_FAILURE)
70 return E_FAILURE_STRING;
73 return "Unknown Error";
76 const char* __errTable1100[] =
78 "E_ADDRESS_CHANGED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1100))
79 "E_ALREADY_BOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1101))
80 "E_ALREADY_CONNECTED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1102))
81 "E_ALREADY_OPENED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1103))
82 "E_AUTHENTICATION", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1104))
83 "E_APP_NOT_INSTALLED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1105))
84 "E_ALREADY_SET", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1106))
85 "E_ACCOUNT_ALREADY_EXIST", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1107))
86 "E_ACCOUNT_NOT_FOUND" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1108))
89 const char* __errTable1300[] =
91 "E_CHUNKED_TRANSACTION", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1300))
92 "E_CONNECTION_BUSY", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1301))
93 "E_CONNECTION_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1302))
94 "E_CONNECTION_RESET", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1303))
95 "E_CREDENTIAL_EXPIRED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1304))
96 "E_CERTIFICATE_VERIFICATION_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1305))
97 "E_CONTEXT_UNAVAILABLE" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1306))
100 const char* __errTable1400[] =
102 "E_DATA_NOT_FOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1400))
103 "E_DATABASE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1401))
104 "E_DECODING_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1402))
105 "E_DEVICE_BUSY", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1403))
106 "E_DEVICE_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1404))
107 "E_DEVICE_INCOMPATIBLE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1405))
108 "E_DEVICE_UNAVAILABLE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1406))
109 "E_DHCP", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1407))
110 "E_DIMENSION_CHANGED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1408))
111 "E_DNS", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1409))
112 "E_DNS_NOT_FOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1410))
113 "E_DATA_NOT_ENOUGH", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1411))
114 "E_DISPLAY_RIGHT_VIOLATED" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1412))
117 const char* __errTable1500[] =
119 "E_EFFECTS_DISABLED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1500))
120 "E_EMPTY_BODY", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1501))
121 "E_ENCODING_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1502))
122 "E_END_OF_FILE" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1503))
125 const char* __errTable1600[] =
127 "E_FDN_MODE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1600))
128 "E_FILE_ALREADY_EXIST", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1601))
129 "E_FILE_NOT_FOUND" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1602))
132 const char* __errTable1700[] =
134 "E_GROUP_NOT_FOUND" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1700))
137 const char* __errTable1800[] =
139 "E_HOST_NOT_FOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1800))
140 "E_HOST_UNREACHABLE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1801))
141 "E_HTTP_USER" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1802))
144 const char* __errTable1900[] =
146 "E_ILLEGAL_ACCESS", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1900))
147 "E_IN_PROGRESS", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1901))
148 "E_INACCESSIBLE_PATH", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1902))
149 "E_INIT_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1903))
150 "E_INSTANTIATION_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1904))
151 "E_INSUFFICIENT_PRIORITY", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1905))
152 "E_INTERRUPTED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1906))
153 "E_INVALID_ACCOUNT", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1907))
154 "E_INVALID_ADDRESS", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1908))
155 "E_INVALID_ARG", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1909))
156 "E_INVALID_CONDITION", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1910))
157 "E_INVALID_CONNECTION", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1911))
158 "E_INVALID_CONTENT", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1912))
159 "E_INVALID_CONTEXT", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1913))
160 "E_INVALID_DATA", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1914))
161 "E_INVALID_DOMAIN", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1915))
162 "E_INVALID_ENCODING_RANGE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1916))
163 "E_INVALID_FORMAT", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1917))
164 "E_INVALID_HEADER", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1918))
165 "E_INVALID_KEY", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1919))
166 "E_INVALID_OPERATION", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1920))
167 "E_INVALID_PROXY", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1921))
168 "E_INVALID_SIM_STATE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1922))
169 "E_INVALID_SERVER", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1923))
170 "E_INVALID_SESSION", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1924))
171 "E_INVALID_SOCKET", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1925))
172 "E_INVALID_STATE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1926))
173 "E_INVALID_TRANSACTION", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1927))
174 "E_IO", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1928))
175 "E_NOT_JOINED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1929))
176 "E_INVALID_CERTIFICATE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1930))
177 "E_INVALID_URL", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1931))
178 "E_INVALID_USER_ID", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1932))
179 "E_INVALID_PASSWORD" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(1933))
183 const char* __errTable2100[] =
185 "E_KEY_ALREADY_EXIST", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2100))
186 "E_KEY_NOT_FOUND" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2101))
189 const char* __errTable2200[] =
191 "E_LANDMARK", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2200))
192 "E_LIBRARY_NOT_FOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2201))
193 "E_LIBRARY_NOT_LOADED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2202))
194 "E_LINK", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2203))
195 "E_LOCATION", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2204))
196 "E_LOCATION_SERVICE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2205))
197 "E_LOCK_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2206))
198 "E_LANGUAGE_NOT_SET", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2207))
199 "E_LOCATION_UNAVAILABLE" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2208))
202 const char* __errTable2300[] =
204 "E_MAX_EXCEEDED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2300))
205 "E_MISSING_INPUT", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2301))
206 "E_MOBILE_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2302))
207 "E_MODEL_NOT_FOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2303))
208 "E_MEMBER_ALREADY_EXIST" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2304))
211 const char* __errTable2400[] =
213 "E_NETWORK_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2400))
214 "E_NETWORK_UNAVAILABLE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2401))
215 "E_NO_CERTIFICATE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2402))
216 "E_NOT_A_MEMBER", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2403))
217 "E_NOT_PAIRED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2404))
218 "E_NOT_RESPONDING", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2405))
219 "E_NUM_FORMAT" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2406))
222 const char* __errTable2500[] =
224 "E_OBJ_ALREADY_EXIST", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2500))
225 "E_OBJ_NOT_FOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2501))
226 "E_OBJECT_LOCKED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2502))
227 "E_ON_INITIALIZING", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2503))
228 "E_OPERATION_CANCELED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2504))
229 "E_OPERATION_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2505))
230 "E_OUT_OF_MEMORY", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2506))
231 "E_OUT_OF_RANGE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2507))
232 "E_OVERFLOW", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2508))
233 "E_OPENGL_ERROR", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2509))
234 "E_OBJ_NOT_REGISTERED" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2510))
237 const char* __errTable2600[] =
239 "E_PAIRING_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2600))
240 "E_PARSING_FAILED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2601))
241 "E_PRIVILEGE_DENIED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2602))
242 "E_PKG_NOT_INSTALLED" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2603))
245 const char* __errTable2800[] =
247 "E_READ_ONLY", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2800))
248 "E_REJECTED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2801))
249 "E_REMOTE_DEVICE_NOT_FOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2802))
250 "E_REMOVE_SERVICE_NOT_FOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2803))
251 "E_RESOURCE_UNAVAILABLE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2804))
252 "E_RIGHT_EXPIRED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2805))
253 "E_RIGHT_NO_LICENSE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2806))
254 "E_RIGHT_FUTURE_USE" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2807))
257 const char* __errTable2900[] =
259 "E_SECTION_ALREADY_EXIST", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2900))
260 "E_SECTION_NOT_FOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2901))
261 "E_SERVER", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2902))
262 "E_SERVICE_BUSY", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2903))
263 "E_SERVICE_LIMITED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2904))
264 "E_SERVICE_LOCKED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2905))
265 "E_SERVICE_UNAVAILABLE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2906))
266 "E_SESSION_DEACTIVATED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2907))
267 "E_SESSION_UNAVAILABLE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2908))
268 "E_SIZE_MISMATCH", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2909))
269 "E_SOCKET_USER", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2910))
270 "E_STORAGE_FULL", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2911))
271 "E_SYMBOL_NOT_FOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2912))
272 "E_SYNTAX", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2913))
273 "E_SYSTEM", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2914))
274 "E_SERVICE_DEACTIVATED " //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(2915))
277 const char* __errTable3000[] =
279 "E_TABLE_NOT_FOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3000))
280 "E_TIMEOUT", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3001))
281 "E_TYPE_MISMATCH" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3002))
284 const char* __errTable3100[] =
286 "E_UNDERFLOW", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3100))
287 "E_UNKNOWN", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3101))
288 "E_UNSUPPORTED_ALGORITHM", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3102))
289 "E_UNSUPPORTED_CODEC", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3103))
290 "E_UNSUPPORTED_FAMILY", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3104))
291 "E_UNSUPPORTED_FORMAT", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3105))
292 "E_UNSUPPORTED_PROTOCOL", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3106))
293 "E_UNSUPPORTED_OPERATION", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3107))
294 "E_UNSUPPORTED_OPTION", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3108))
295 "E_UNSUPPORTED_SERVICE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3109))
296 "E_UNSUPPORTED_TYPE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3110))
297 "E_URL_CHANGED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3111))
298 "E_USER_AGENT_NOT_ALLOWED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3112))
299 "E_USER_ALREADY_REGISTERED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3113))
300 "E_USER_NOT_FOUND", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3114))
301 "E_USER_NOT_REGISTERED", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3115))
302 "E_UNSUPPORTED_LANGUAGE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3116))
303 "E_UNSUPPORTED_VERSION", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3117))
304 "E_UNSUPPORTED_LOCALE", //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3118))
305 "E_USER_NOT_CONSENTED" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3119))
308 const char* __errTable3300[] =
310 "E_WOULD_BLOCK" //(ERR_SRC_FRAMEWORK + SET_E_CAUSE(3300))
313 // Add the error tables in sorted order. Then we can use binary search.
314 // else we will have to use sequential search
315 ErrTableType __gErrTable[] =
317 ERR_TABLE_INITIALIZER(1100),
318 ERR_TABLE_INITIALIZER(1300),
319 ERR_TABLE_INITIALIZER(1400),
320 ERR_TABLE_INITIALIZER(1500),
321 ERR_TABLE_INITIALIZER(1600),
322 ERR_TABLE_INITIALIZER(1700),
323 ERR_TABLE_INITIALIZER(1800),
324 ERR_TABLE_INITIALIZER(1900),
325 ERR_TABLE_INITIALIZER(2100),
326 ERR_TABLE_INITIALIZER(2200),
327 ERR_TABLE_INITIALIZER(2300),
328 ERR_TABLE_INITIALIZER(2400),
329 ERR_TABLE_INITIALIZER(2500),
330 ERR_TABLE_INITIALIZER(2600),
331 ERR_TABLE_INITIALIZER(2800),
332 ERR_TABLE_INITIALIZER(2900),
333 ERR_TABLE_INITIALIZER(3000),
334 ERR_TABLE_INITIALIZER(3100),
335 ERR_TABLE_INITIALIZER(3300)
345 SetLastResult(result r)
351 ClearLastResult(void)
353 lastResult = E_SUCCESS;
358 GetErrorMessage(result value)
360 return __BinarySearchErrorTable(__gErrTable, value, 0, (ARR_ITEM_COUNT(__gErrTable) - 1));
363 #define MAX_CHECK_COUNT 100
364 _OSP_EXPORT_ result TransExceptionsExclusiveInternal(result r, result e, int num, ...);
366 _OSP_EXPORT_ result TransExceptionsInclusiveInternal(result r, result e, int num, ...);
369 TransExceptionsExclusiveInternal(result r, result e, int num, ...)
381 for (; count < num; count++)
383 if (r == va_arg(ap, result))
400 TransExceptionsInclusiveInternal(result r, result e, int num, ...)
412 for (; count < num; count++)
414 if (r == va_arg(ap, result))