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 "PowerUtil.h"
21 #include <PlatformException.h>
27 using namespace DeviceAPI::Common;
29 void PowerUtil::throwPowerException(const int errorCode, const std::string &hint)
32 ss << hint << " : " << getPowerErrorMessage(errorCode);
33 LOGE("%s", ss.str().c_str());
36 case DEVICE_ERROR_INVALID_PARAMETER:
37 throw InvalidValuesException(ss.str().c_str());
38 case DEVICE_ERROR_PERMISSION_DENIED:
39 throw SecurityException(ss.str().c_str());
41 throw UnknownException(ss.str().c_str());
45 std::string PowerUtil::getPowerErrorMessage(const int errorCode)
47 LOGE("%d", errorCode);
50 case DEVICE_ERROR_OPERATION_FAILED:
51 return "Operation failed";
52 case DEVICE_ERROR_PERMISSION_DENIED:
53 return "Permission denied";
54 case DEVICE_ERROR_INVALID_PARAMETER:
55 return "Invalid Parameter";
56 case DEVICE_ERROR_ALREADY_IN_PROGRESS:
57 return "Operation already in progress";
58 case DEVICE_ERROR_NOT_SUPPORTED:
59 return "Not supported";
60 case DEVICE_ERROR_NOT_INITIALIZED:
61 return "Not initialized";
63 return "Unknown Error";