2 // Tizen Web Device API
3 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "AccountUtil.h"
22 #include <PlatformException.h>
28 using namespace DeviceAPI::Common;
30 void AccountUtil::throwAccountException(const int errorCode,
31 const std::string &hint)
36 ss << hint << " : " << getAccountErrorMessage(errorCode);
37 LOGE("%s", ss.str().c_str());
40 case ACCOUNT_ERROR_RECORD_NOT_FOUND:
41 throw NotFoundException(ss.str().c_str());
43 throw UnknownException(ss.str().c_str());
47 std::string AccountUtil::getAccountErrorMessage(const int errorCode)
50 case ACCOUNT_ERROR_OUT_OF_MEMORY:
51 return "Out of Memory";
52 case ACCOUNT_ERROR_INVALID_PARAMETER:
53 return "Invalid Parameter";
54 case ACCOUNT_ERROR_DUPLICATED:
55 return "Same user name exists in your application";
56 case ACCOUNT_ERROR_NO_DATA:
58 case ACCOUNT_ERROR_RECORD_NOT_FOUND:
59 return "Related record does not exist";
60 case ACCOUNT_ERROR_DB_FAILED:
61 return "DB operation failed";
62 case ACCOUNT_ERROR_DB_NOT_OPENED:
63 return "DB is not connected";
64 case ACCOUNT_ERROR_QUERY_SYNTAX_ERROR:
65 return "DB query syntax error";
66 case ACCOUNT_ERROR_ITERATOR_END:
67 return "Iterator has reached the end";
68 case ACCOUNT_ERROR_NOTI_FAILED:
69 return "Notification failed";
70 case ACCOUNT_ERROR_PERMISSION_DENIED:
71 return "Permission denied";
72 case ACCOUNT_ERROR_XML_PARSE_FAILED:
73 return "XML parse failed";
74 case ACCOUNT_ERROR_XML_FILE_NOT_FOUND:
75 return "XML file does not exist";
76 case ACCOUNT_ERROR_EVENT_SUBSCRIPTION_FAIL:
77 return "Subscription failed";
78 case ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER:
79 return "Account provider is not registered";
80 case ACCOUNT_ERROR_NOT_ALLOW_MULTIPLE:
81 return "Multiple accounts are not supported";
82 case ACCOUNT_ERROR_DATABASE_BUSY:
83 return "SQLite busy handler expired";
85 return "Unknown Error";