Fix N_SE-32099 : zero length string may not save to setting.xml
[platform/framework/native/appfw.git] / src / base / FBase_NativeError.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FBaseNativeError.cpp
20  * @brief               This is the implementation file of functions for native error handling.
21  */
22
23 #include <string.h>
24 #include <errno.h>
25 #include <system_info.h>
26 #include <power.h>
27 #include <alarm.h>
28 #include "FBase_NativeError.h"
29 #include <FBaseSysLog.h>
30 #include "device.h"
31 #include "sqlite3.h"
32
33
34
35 using namespace Tizen::Base;
36
37 static int nativeErrorToResultTable[] =
38 {
39 E_SUCCESS,                  // SUCCESS           0      /* Success, No error */
40 E_INVALID_OPERATION,        // EPERM             1      /* Operation not permitted */
41 E_FILE_NOT_FOUND,           // ENOENT            2      /* No such file or directory */
42 E_UNKNOWN,                  // ESRCH             3      /* No such process */
43 E_INTERRUPTED,              // EINTR             4      /* Interrupted system call */
44 E_IO,                       // EIO                   5  /* I/O error */
45 E_OBJ_NOT_FOUND,            // ENXIO             6      /* No such device or address */
46 E_OVERFLOW,                 // E2BIG             7      /* Argument list too long */
47 E_UNKNOWN,                  // ENOEXEC           8      /* Exec format error */
48 E_FILE_NOT_FOUND,           // EBADF             9      /* Bad file number */
49 E_UNKNOWN,                  // ECHILD           10      /* No child processes */
50 E_UNKNOWN,                  // EAGAIN           11      /* Try again */
51 E_OUT_OF_MEMORY,            // ENOMEM           12      /* Out of memory */
52 E_ILLEGAL_ACCESS,           // EACCES           13      /* Permission denied */
53 E_UNKNOWN,                  // EFAULT           14      /* Bad address */
54 E_UNKNOWN,                  // ENOTBLK          15      /* Block device required */
55 E_DEVICE_BUSY,              // EBUSY            16      /* Device or resource busy */
56 E_FILE_ALREADY_EXIST,       // EEXIST           17      /* File exists */
57 E_UNKNOWN,                  // EXDEV            18      /* Cross-device link */
58 E_IO,                       // ENODEV           19      /* No such device */
59 E_INVALID_ARG,              // ENOTDIR          20      /* Not a directory */
60 E_INVALID_ARG,              // EISDIR           21      /* Is a directory */
61 E_INVALID_ARG,              // EINVAL           22      /* Invalid argument */
62 E_MAX_EXCEEDED,             // ENFILE           23      /* File table overflow */
63 E_MAX_EXCEEDED,             // EMFILE           24      /* Too many open files */
64 E_UNKNOWN,                  // ENOTTY           25      /* Not a typewriter */
65 E_UNKNOWN,                  // ETXTBSY          26      /* Text file busy */
66 E_IO,                       // EFBIG            27      /* File too large */
67 E_STORAGE_FULL,             // ENOSPC           28      /* No space left on device */
68 E_ILLEGAL_ACCESS,           // ESPIPE           29      /* Illegal seek */
69 E_ILLEGAL_ACCESS,           // EROFS            30      /* Read-only file system */
70 E_UNKNOWN,                  // EMLINK           31      /* Too many links */
71 E_UNKNOWN,                  // EPIPE            32      /* Broken pipe */
72 E_INVALID_DOMAIN,           // EDOM                     33      /* Math argument out of domain of func */
73 E_OUT_OF_RANGE,             // ERANGE           34      /* Math result not representable ;
74 E_UNKNOWN,                  // EDEADLK          35      /* Resource deadlock would occur */
75 E_INVALID_ARG,              // ENAMETOOLONG     36      /* File name too long */
76 E_UNKNOWN,                  // ENOLCK           37      /* No record locks available */
77 E_UNKNOWN,                  // ENOSYS           38      /* Function not implemented */
78 E_UNKNOWN,                  // ENOTEMPTY        39      /* Directory not empty */
79 E_INVALID_ARG,              // ELOOP            40      /* Too many symbolic links encountered */
80 E_WOULD_BLOCK,              // EWOULDBLOCK      EAGAIN  /* Operation would block */
81 E_UNKNOWN,                  // ENOMSG           42      /* No message of desired type */
82 E_UNKNOWN,                  // EIDRM            43      /* Identifier removed */
83 E_UNKNOWN,                  // ECHRNG           44      /* Channel number out of range */
84 E_UNKNOWN,                  // EL2NSYNC         45      /* Level 2 not synchronized */
85 E_UNKNOWN,                  // EL3HLT           46      /* Level 3 halted */
86 E_UNKNOWN,                  // EL3RST           47      /* Level 3 reset */
87 E_UNKNOWN,                  // ELNRNG           48      /* Link number out of range */
88 E_UNKNOWN,                  // EUNATCH          49      /* Protocol driver not attached */
89 E_UNKNOWN,                  // ENOCSI           50      /* No CSI structure available */
90 E_UNKNOWN,                  // EL2HLT           51      /* Level 2 halted */
91 E_UNKNOWN,                  // EBADE            52      /* Invalid exchange */
92 E_UNKNOWN,                  // EBADR            53      /* Invalid request descriptor */
93 E_UNKNOWN,                  // EXFULL           54      /* Exchange full */
94 E_UNKNOWN,                  // ENOANO           55      /* No anode */
95 E_UNKNOWN,                  // EBADRQC          56      /* Invalid request code */
96 E_UNKNOWN,                  // EBADSLT          57      /* Invalid slot */
97
98 E_UNKNOWN,                  // EDEADLOCK        EDEADLK
99
100 E_UNKNOWN,                  // EBFONT           59      /* Bad font file format */
101 E_UNKNOWN,                  // ENOSTR           60      /* Device not a stream */
102 E_UNKNOWN,                  // ENODATA          61      /* No data available */
103 E_UNKNOWN,                  // ETIME            62      /* Timer expired */
104 E_UNKNOWN,                  // ENOSR            63      /* Out of streams resources */
105 E_UNKNOWN,                  // ENONET           64      /* Machine is not on the network */
106 E_UNKNOWN,                  // ENOPKG           65      /* Package not installed */
107 E_UNKNOWN,                  // EREMOTE          66      /* Object is remote */
108 E_UNKNOWN,                  // ENOLINK          67      /* Link has been severed */
109 E_UNKNOWN,                  // EADV                     68      /* Advertise error */
110 E_UNKNOWN,                  // ESRMNT           69      /* Srmount error */
111 E_UNKNOWN,                  // ECOMM            70      /* Communication error on send */
112 E_UNKNOWN,                  // EPROTO           71      /* Protocol error */
113 E_UNKNOWN,                  // EMULTIHOP        72      /* Multihop attempted */
114 E_UNKNOWN,                  // EDOTDOT          73      /* RFS specific error */
115 E_UNKNOWN,                  // EBADMSG          74      /* Not a data message */
116 E_IO,                       // EOVERFLOW        75      /* Value too large for defined data type */
117 E_UNKNOWN,                  // ENOTUNIQ         76      /* Name not unique on network */
118 E_UNKNOWN,                  // EBADFD           77      /* File descriptor in bad state */
119 E_UNKNOWN,                  // EREMCHG          78      /* Remote address changed */
120 E_UNKNOWN,                  // ELIBACC          79      /* Can not access a needed shared library */
121 E_UNKNOWN,                  // ELIBBAD          80      /* Accessing a corrupted shared library */
122 E_UNKNOWN,                  // ELIBSCN          81      /* .lib section in a.out corrupted */
123 E_UNKNOWN,                  // ELIBMAX          82      /* Attempting to link in too many shared libraries */
124 E_UNKNOWN,                  // ELIBEXEC         83      /* Cannot exec a shared library directly */
125 E_INVALID_ENCODING_RANGE,       // EILSEQ               84      /* Illegal byte sequence */
126 E_UNKNOWN,                  // ERESTART         85      /* Interrupted system call should be restarted */
127 E_UNKNOWN,                  // ESTRPIPE         86      /* Streams pipe error */
128 E_UNKNOWN,                  // EUSERS           87      /* Too many users */
129 E_UNKNOWN,                  // ENOTSOCK         88      /* Socket operation on non-socket */
130 E_UNKNOWN,                  // EDESTADDRREQ     89      /* Destination address required */
131 E_UNKNOWN,                  // EMSGSIZE         90      /* Message too long */
132 E_UNKNOWN,                  // EPROTOTYPE       91      /* Protocol wrong type for socket */
133 E_UNKNOWN,                  // ENOPROTOOPT      92      /* Protocol not available */
134 E_UNSUPPORTED_PROTOCOL,     // EPROTONOSUPPORT  93      /* Protocol not supported */
135 E_UNKNOWN,                  // ESOCKTNOSUPPORT  94      /* Socket type not supported */
136 E_UNSUPPORTED_OPERATION,    // EOPNOTSUPP       95      /* Operation not supported on transport endpoint */
137 E_UNKNOWN,                  // EPFNOSUPPORT     96      /* Protocol family not supported */
138 E_UNKNOWN,                  // EAFNOSUPPORT     97      /* Address family not supported by protocol */
139 E_UNKNOWN,                  // EADDRINUSE       98      /* Address already in use */
140 E_UNKNOWN,                  // EADDRNOTAVAIL    99      /* Cannot assign requested address */
141 E_UNKNOWN,                  // ENETDOWN         100     /* Network is down */
142 E_UNKNOWN,                  // ENETUNREACH      101     /* Network is unreachable */
143 E_UNKNOWN,                  // ENETRESET        102     /* Network dropped connection because of reset */
144 E_UNKNOWN,                  // ECONNABORTED     103     /* Software caused connection abort */
145 E_UNKNOWN,                  // ECONNRESET       104     /* Connection reset by peer */
146 E_UNKNOWN,                  // ENOBUFS          105     /* No buffer space available */
147 E_UNKNOWN,                  // EISCONN          106     /* Transport endpoint is already connected */
148 E_UNKNOWN,                  // ENOTCONN         107     /* Transport endpoint is not connected */
149 E_UNKNOWN,                  // ESHUTDOWN        108     /* Cannot send after transport endpoint shutdown */
150 E_UNKNOWN,                  // ETOOMANYREFS     109     /* Too many references: cannot splice */
151 E_UNKNOWN,                  // ETIMEDOUT        110     /* Connection timed out */
152 E_UNKNOWN,                  // ECONNREFUSED     111     /* Connection refused */
153 E_UNKNOWN,                  // EHOSTDOWN        112     /* Host is down */
154 E_HOST_UNREACHABLE,         // EHOSTUNREACH     113     /* No route to host */
155 E_UNKNOWN,                  // EALREADY         114     /* Operation already in progress */
156 E_UNKNOWN,                  // EINPROGRESS      115     /* Operation now in progress */
157 E_UNKNOWN,                  // ESTALE           116     /* Stale NFS file handle */
158 E_UNKNOWN,                  // EUCLEAN          117     /* Structure needs cleaning */
159 E_UNKNOWN,                  // ENOTNAM          118     /* Not a XENIX named type file */
160 E_UNKNOWN,                  // ENAVAIL          119     /* No XENIX semaphores available */
161 E_UNKNOWN,                  // EISNAM           120     /* Is a named type file */
162 E_UNKNOWN,                  // EREMOTEIO        121     /* Remote I/O error */
163 E_UNKNOWN,                  // EDQUOT           122     /* Quota exceeded */
164
165 E_UNKNOWN,                  // ENOMEDIUM        123     /* No medium found */
166 E_UNKNOWN,                  // EMEDIUMTYPE      124     /* Wrong medium type */
167 E_UNKNOWN,                  // ECANCELED        125     /* Operation Canceled */
168 E_UNKNOWN,                  // ENOKEY           126     /* Required key not available */
169 E_UNKNOWN,                  // EKEYEXPIRED      127     /* Key has expired */
170 E_UNKNOWN,                  // EKEYREVOKED      128     /* Key has been revoked */
171 E_UNKNOWN,                  // EKEYREJECTED     129     /* Key was rejected by service */
172
173 /* for robust mutexes */
174 E_UNKNOWN,                  // EOWNERDEAD       130     /* Owner died */
175 E_UNKNOWN,                  // ENOTRECOVERABLE  131     /* State not recoverable */
176 };
177
178 static int sqlErrorToResultTable[] =
179 {
180         E_SUCCESS,              // SQLITE_OK           0   /* Successful result */
181         E_DATABASE,                             // SQLITE_ERROR        1   /* SQL error or missing database */
182         E_DATABASE,             // SQLITE_INTERNAL     2   /* Internal logic error in SQLite */
183         E_DATABASE,             // SQLITE_PERM         3   /* Access permission denied */
184         E_DATABASE,             // SQLITE_ABORT        4   /* Callback routine requested an abort */
185         E_SERVICE_BUSY,         // SQLITE_BUSY         5   /* The database file is locked */
186         E_DATABASE,             // SQLITE_LOCKED       6   /* A table in the database is locked */
187         E_DATABASE,             // SQLITE_NOMEM        7   /* A malloc() failed */
188         E_DATABASE,             // SQLITE_READONLY     8   /* Attempt to write a readonly database */
189         E_DATABASE,             // SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/
190         E_DATABASE,             // SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */
191         E_DATABASE,             // SQLITE_CORRUPT     11   /* The database disk image is malformed */
192         E_DATABASE,             // SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */
193         E_DATABASE,             // SQLITE_FULL        13   /* Insertion failed because database is full */
194         E_FILE_NOT_FOUND,       // SQLITE_CANTOPEN    14   /* Unable to open the database file */
195         E_DATABASE,             // SQLITE_PROTOCOL    15   /* Database lock protocol error */
196         E_DATABASE,             // SQLITE_EMPTY       16   /* Database is empty */
197         E_DATABASE,             // SQLITE_SCHEMA      17   /* The database schema changed */
198         E_INVALID_ARG,          // SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */
199         E_DATABASE,             // SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */
200         E_DATABASE,             // SQLITE_MISMATCH    20   /* Data type mismatch */
201         E_DATABASE,             // SQLITE_MISUSE      21   /* Library used incorrectly */
202         E_DATABASE,             // SQLITE_NOLFS       22   /* Uses OS features not supported on host */
203         E_DATABASE,             // SQLITE_AUTH        23   /* Authorization denied */
204         E_DATABASE,             // SQLITE_FORMAT      24   /* Auxiliary database format error */
205         E_INVALID_ARG,          // SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */
206         E_DATABASE,             // SQLITE_NOTADB      26   /* File opened that is not a database file */
207 };
208
209 static int sqlErrorToDetailResultTable[] =
210 {
211         E_SUCCESS,              // SQLITE_OK           0   /* Successful result */
212         E_INVALID_ARG,          // SQLITE_ERROR        1   /* SQL error or missing database */
213         E_SYSTEM,               // SQLITE_INTERNAL     2   /* Internal logic error in SQLite */
214         E_ILLEGAL_ACCESS,       // SQLITE_PERM         3   /* Access permission denied */
215         E_UNKNOWN,              // SQLITE_ABORT        4   /* Callback routine requested an abort */
216         E_OBJECT_LOCKED,        // SQLITE_BUSY         5   /* The database file is locked */
217         E_OBJECT_LOCKED,        // SQLITE_LOCKED       6   /* A table in the database is locked */
218         E_OUT_OF_MEMORY,        // SQLITE_NOMEM        7   /* A malloc() failed */
219         E_ILLEGAL_ACCESS,       // SQLITE_READONLY     8   /* Attempt to write a readonly database */
220         E_UNKNOWN,              // SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/
221         E_IO,                   // SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */
222         E_INVALID_FORMAT,       // SQLITE_CORRUPT     11   /* The database disk image is malformed */
223         E_SYSTEM,               // SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */
224         E_STORAGE_FULL,         // SQLITE_FULL        13   /* Insertion failed because database is full */
225         E_FILE_NOT_FOUND,       // SQLITE_CANTOPEN    14   /* Unable to open the database file */
226         E_UNKNOWN,              // SQLITE_PROTOCOL    15   /* Database lock protocol error */
227         E_UNKNOWN,              // SQLITE_EMPTY       16   /* Database is empty */
228         E_INVALID_ARG,          // SQLITE_SCHEMA      17   /* The database schema changed */
229         E_INVALID_ARG,          // SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */
230         E_INVALID_ARG,          // SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */
231         E_INVALID_ARG,          // SQLITE_MISMATCH    20   /* Data type mismatch */
232         E_INVALID_OPERATION,    // SQLITE_MISUSE      21   /* Library used incorrectly */
233         E_SYSTEM,               // SQLITE_NOLFS       22   /* Uses OS features not supported on host */
234         E_ILLEGAL_ACCESS,       // SQLITE_AUTH        23   /* Authorization denied */
235         E_INVALID_FORMAT,       // SQLITE_FORMAT      24   /* Auxiliary database format error */
236         E_INVALID_ARG,          // SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */
237         E_INVALID_FORMAT,       // SQLITE_NOTADB      26   /* File opened that is not a database file */
238 };
239
240 result
241 _NativeError::ConvertNativeErrorToResult(int errNo, const char* pFile, int line, const char* pFunction, bool logNativeErr)
242 {
243         result r = E_UNKNOWN;
244
245         if ((errNo >= 0) && (errNo < (int) (sizeof(nativeErrorToResultTable) / sizeof(nativeErrorToResultTable[0]))))
246         {
247                 r = nativeErrorToResultTable[errNo];
248         }
249
250         if (logNativeErr)
251         {
252                 SysLog(NID_BASE, "A native error (%d) occurred at (%s:%d).", errNo, pFile, line);
253         }
254
255         if (r == E_UNKNOWN)
256         {
257                 SysLog(NID_BASE, "[E_SYSTEM] Failed to convert native error (%d, %s) to result.", errNo, strerror(errNo));
258                 return E_SYSTEM;
259         }
260
261         return r;
262 }
263
264 result
265 _NativeError::ConvertNativeErrorToResult(int errNo, bool logNativeErr)
266 {
267         result r = E_UNKNOWN;
268
269         if ((errNo >= 0) && (errNo < (int) (sizeof(nativeErrorToResultTable) / sizeof(nativeErrorToResultTable[0]))))
270         {
271                 r = nativeErrorToResultTable[errNo];
272         }
273
274         if (logNativeErr)
275         {
276                 SysLog(NID_BASE, "A native error (%d) occurred.", errNo);
277         }
278
279         if (r == E_UNKNOWN)
280         {
281                 SysLog(NID_BASE, "[E_SYSTEM] Failed to convert native error (%d, %s) to result.", errNo, strerror(errNo));
282                 return E_SYSTEM;
283         }
284
285         return r;
286 }
287
288 const char*
289 _NativeError::ConvertNativeErrorToMessage(int errNo, const char* pFile, int line, const char* pFunction)
290 {
291         return GetErrorMessage(ConvertNativeErrorToResult(errNo, pFile, line, pFunction));
292 }
293
294 const char*
295 _NativeError::ConvertNativeErrorToMessage(int errNo)
296 {
297         return GetErrorMessage(__ConvertNativeErrorToResult(errNo));
298 }
299
300 result
301 _NativeError::ConvertNativeSystemErrorToResult(int err)
302 {
303         switch (err)
304         {
305         case SYSTEM_INFO_ERROR_INVALID_PARAMETER:
306                 return E_INVALID_ARG;
307                 //case SYSTEM_INFO_ERROR_INTERNAL: return E_SYSTEM;
308                 //case SYSTEM_INFO_ERROR_OUT_OF_MEMORY: return E_OUT_OF_MEMORY;
309                 //case SYSTEM_INFO_ERROR_IO : return E_IO;
310         }
311
312         return E_UNKNOWN;
313 }
314
315 result
316 _NativeError::ConvertNativeDeviceErrorToResult(int err)
317 {
318         switch (err)
319         {
320 //      case DEVICE_ERROR_UNKNOWN: return E_SYSTEM;
321         case DEVICE_ERROR_INVALID_PARAMETER:
322                 return E_INVALID_ARG;
323         }
324
325         return E_UNKNOWN;
326 }
327
328 result
329 _NativeError::ConvertNativePowerErrorToResult(int err)
330 {
331         switch (err)
332         {
333 //      case POWER_ERROR_UNKNOWN: return E_SYSTEM;
334         case POWER_ERROR_INVALID_PARAMETER:
335                 return E_INVALID_ARG;
336         }
337
338         return E_UNKNOWN;
339 }
340
341 result
342 _NativeError::ConvertNativeAlarmErrorToResult(int err)
343 {
344         switch (err)
345         {
346         case ERR_ALARM_INVALID_PARAM:
347                 return E_INVALID_ARG;
348
349         case ERR_ALARM_INVALID_ID:
350                 return E_INVALID_ARG;
351
352         case ERR_ALARM_INVALID_REPEAT:
353                 return E_INVALID_ARG;
354
355         case ERR_ALARM_INVALID_TIME:
356                 return E_INVALID_ARG;
357
358         case ERR_ALARM_INVALID_DATE:
359                 return E_INVALID_ARG;
360
361         case ERR_ALARM_NO_SERVICE_NAME:
362                 return E_INVALID_ARG;
363
364         case ERR_ALARM_SYSTEM_FAIL:
365                 return E_SYSTEM;
366         }
367
368         return E_UNKNOWN;
369 }
370
371 result
372 _NativeError::ConvertNativeHapticErrorToResult(int err)
373 {
374         switch (err)
375         {
376                 //case HAPTIC_ERROR_UNKNOWN: return E_SYSTEM;
377                 //case HAPTIC_ERROR_INVALID_PARAMETER: return E_INVALID_ARG;
378                 //case HAPTIC_ERROR_OPENED_DEVICE: return E_INVALID_STATE;
379         }
380
381         return E_UNKNOWN;
382 }
383
384 result
385 _NativeError::ConvertNativeTelephonyErrorToResult(int err)
386 {
387         switch (err)
388         {
389                 /* deprecated on SLP SDK RC 11 */
390 //      case TELEPHONY_ERROR_INTERNAL: return E_SYSTEM;
391 //      case TELEPHONY_ERROR_INVALID_PARAMETER: return E_INVALID_ARG;
392 //      case TELEPHONY_ERROR_OUT_OF_SERVICE: return E_SERVICE_DEACTIVATED;
393 //      case TELEPHONY_ERROR_OUT_OF_MEMORY: return E_OUT_OF_MEMORY;
394         }
395
396         return E_UNKNOWN;
397 }
398
399 result
400 _NativeError::ConvertNativeSoundManagerErrorToResult(int err)
401 {
402         switch (err)
403         {
404 //      case SOUND_MANAGER_NO_PLAYING_SOUND: return E_SYSTEM;
405 //      case SOUND_MANAGER_INVALID_PARAMETER: return E_INVALID_ARG;
406 //      case SOUND_MANAGER_INVALID_OPERATION: return E_INVALID_OPERATION;
407 //      case SOUND_MANAGER_OUT_OF_MEMORY: return E_OUT_OF_MEMORY;
408         }
409
410         return E_UNKNOWN;
411 }
412
413 result
414 _NativeError::ConvertNativeSqliteErrorToResult(int err)
415 {
416         result r = E_UNKNOWN;
417
418         if ((err >= 0) && (err < (int) (sizeof(sqlErrorToResultTable) / sizeof(sqlErrorToResultTable[0]))))
419         {
420                 r = sqlErrorToResultTable[err];
421         }
422
423         if (r == E_UNKNOWN)
424         {
425                 SysLog(NID_BASE, "[E_SYSTEM] Failed to convert native error (%d) to result.", err);
426                 return E_SYSTEM;
427         }
428
429         return r;
430 }
431
432 result
433 _NativeError::ConvertNativeSqliteErrorToDetailResult(int err)
434 {
435         result r = E_UNKNOWN;
436
437         if ((err >= 0) && (err < (int) (sizeof(sqlErrorToDetailResultTable) / sizeof(sqlErrorToDetailResultTable[0]))))
438         {
439                 r = sqlErrorToDetailResultTable[err];
440         }
441
442         if (r == E_UNKNOWN)
443         {
444                 SysLog(NID_BASE, "[E_SYSTEM] Failed to convert native error (%d) to result.", err);
445                 return E_SYSTEM;
446         }
447
448         return r;
449 }
450