1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_UTILS_ERRORS_H 16 #define FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_UTILS_ERRORS_H 17 18 #include <errors.h> 19 #include <map> 20 21 namespace OHOS { 22 namespace WorkScheduler { 23 const int OFFSET = 100; 24 const int THRESHOLD = 1000; 25 enum { 26 E_PERMISSION_DENIED = 201, 27 E_PARAM_ERROR = 401, 28 E_MEMORY_OPERATION_FAILED = 970000101, 29 E_PARCEL_OPERATION_FAILED = 970000201, 30 E_CLIENT_CONNECT_SERVICE_FAILED = 970000301, 31 E_SERVICE_NOT_READY, 32 E_CHECK_WORKINFO_FAILED = 970000401, 33 E_WORK_NOT_EXIST_FAILED, 34 E_ADD_REPEAT_WORK_ERR = 970000501, 35 E_WORK_EXCEED_UPPER_LIMIT, 36 E_REPEAT_CYCLE_TIME_ERR, 37 E_INVALID_PROCESS_NAME, 38 // inner error code 39 E_INNER_ERR, 40 E_GROUP_CHANGE_NOT_MATCH_HAP, 41 }; 42 43 enum ParamError { 44 E_PARAM_NUMBER_ERR = 9700401, 45 E_WORK_INFO_TYPE_ERR, 46 E_BUNDLE_OR_ABILITY_NAME_ERR, 47 E_WORKID_ERR, 48 E_CALLBACK_TYPE_ERR, 49 E_CONDITION_EMPTY, 50 E_NETWORK_TYPE_ERR, 51 E_CHARGER_TYPE_ERR, 52 E_IS_CHARGING_ERR, 53 E_BATTERY_LEVEL_ERR, 54 E_BATTERY_STATUS_ERR, 55 E_STORAGE_REQUEST_ERR, 56 E_REPEAT_COUNT_ERR, 57 E_REPEAT_CYCLE_TIME_TYPE_ERR, 58 E_IS_REPEAT_ERR, 59 E_IS_PERSISTED_ERR, 60 E_IS_DEEP_IDLE_ERR, 61 E_PARAMETERS_TYPE_ERR, 62 E_NEED_CANCLE_TYPE_ERR, 63 E_UID_NO_MATCHING_WORK_ERR, 64 }; 65 66 const inline std::map<int32_t, std::string> saErrCodeMsgMap = { 67 {E_MEMORY_OPERATION_FAILED, "Memory operation failed. Failed to allocate the memory."}, 68 {E_PARCEL_OPERATION_FAILED, "Parcel operation failed. Failed to read or write the parcel."}, 69 {E_CLIENT_CONNECT_SERVICE_FAILED, "System service operation failed. Failed to connect the system service."}, 70 {E_SERVICE_NOT_READY, "System service operation failed. The service is not ready."}, 71 {E_CHECK_WORKINFO_FAILED, "Check on workInfo failed. Current bundleUid and input uid do not match."}, 72 {E_ADD_REPEAT_WORK_ERR, "Calling startWork failed. The work has been already added."}, 73 {E_REPEAT_CYCLE_TIME_ERR, "StartWork failed. The repeatTime must be greater than or equal to 20 minutes."}, 74 {E_WORK_EXCEED_UPPER_LIMIT, "StartWork failed. Each uid can add up to 10 works."}, 75 {E_INVALID_PROCESS_NAME, "Pause or resume verify failed. caller process name invaild."}, 76 {E_WORK_NOT_EXIST_FAILED, "The workId do not exist."}, 77 }; 78 79 const inline std::map<int32_t, std::string> paramErrCodeMsgMap = { 80 {E_PARAM_NUMBER_ERR, "The number of arguments is wrong."}, 81 {E_WORK_INFO_TYPE_ERR, "The type of workInfo must be {key: value} object."}, 82 {E_BUNDLE_OR_ABILITY_NAME_ERR, "The bundleName and abilityName cannot be empty and must be string."}, 83 {E_WORKID_ERR, "The workId must be number greater than or equal to 0."}, 84 {E_CALLBACK_TYPE_ERR, "The callback should be function."}, 85 {E_CONDITION_EMPTY, "The workinfo condition cannot be empty."}, 86 {E_NETWORK_TYPE_ERR, "The value of networkType ranges from NETWORK_TYPE_ANY to NETWORK_TYPE_ETHERNET."}, 87 {E_CHARGER_TYPE_ERR, "The value of chargerType ranges from CHARGING_PLUGGED_ANY to CHARGING_UNPLUGGED."}, 88 {E_BATTERY_LEVEL_ERR, "The value of batteryLevel ranges from 0 to 100."}, 89 {E_BATTERY_STATUS_ERR, 90 "The value of batteryStatus ranges from BATTERY_STATUS_LOW to BATTERY_STATUS_LOW_OR_OKAY."}, 91 {E_STORAGE_REQUEST_ERR, 92 "The value of storageRequest ranges from STORAGE_LEVEL_LOW to STORAGE_LEVEL_LOW_OR_OKAY."}, 93 {E_REPEAT_COUNT_ERR, "The repeatCount must be number greater than or equal to 0."}, 94 {E_IS_CHARGING_ERR, "The type of isCharging must be boolean."}, 95 {E_REPEAT_CYCLE_TIME_TYPE_ERR, "The type of repeatCycleTime must be number."}, 96 {E_IS_REPEAT_ERR, "The type of isRepeat must be boolean."}, 97 {E_IS_PERSISTED_ERR, "The type of isPersisted must be boolean."}, 98 {E_IS_DEEP_IDLE_ERR, "The type of isDeepIdle must be boolean."}, 99 {E_PARAMETERS_TYPE_ERR, "The type of parameters must be string, boolean or number."}, 100 {E_NEED_CANCLE_TYPE_ERR, "The type of needCancle must be boolean."}, 101 {E_UID_NO_MATCHING_WORK_ERR, "The UID has no matching work."}, 102 {E_PARAM_ERROR, "The input param is error."}, 103 }; 104 } // namespace WorkScheduler 105 } // namespace OHOS 106 #endif // FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_UTILS_ERRORS_H