1 /* 2 * Copyright (c) 2022-2024 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 16 #ifndef OHOS_ABILITY_RUNTIME_ABILITY_BUSINESS_ERROR_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_BUSINESS_ERROR_H 18 19 #include <string> 20 21 namespace OHOS { 22 namespace AbilityRuntime { 23 enum class AbilityErrorCode { 24 // success 25 ERROR_OK = 0, 26 27 // no such permission. 28 ERROR_CODE_PERMISSION_DENIED = 201, 29 30 // non-system-app use system-api. 31 ERROR_CODE_NOT_SYSTEM_APP = 202, 32 33 // invalid param. 34 ERROR_CODE_INVALID_PARAM = 401, 35 36 // capability not support. 37 ERROR_CODE_CAPABILITY_NOT_SUPPORT = 801, 38 39 // common inner error. 40 ERROR_CODE_INNER = 16000050, 41 42 // can not find target ability. 43 ERROR_CODE_RESOLVE_ABILITY = 16000001, 44 45 // ability type is wrong. 46 ERROR_CODE_INVALID_ABILITY_TYPE = 16000002, 47 48 // id does not exist. 49 ERROR_CODE_INVALID_ID = 16000003, 50 51 // no start invisible ability permission. 52 ERROR_CODE_NO_INVISIBLE_PERMISSION = 16000004, 53 54 // check static permission failed. 55 ERROR_CODE_STATIC_CFG_PERMISSION = 16000005, 56 57 // no permission to cross user. 58 ERROR_CODE_CROSS_USER = 16000006, 59 60 // Service busy.Try again later. 61 ERROR_CODE_SERVICE_BUSY = 16000007, 62 63 // crowdtest app expiration. 64 ERROR_CODE_CROWDTEST_EXPIRED = 16000008, 65 66 // wukong mode. 67 ERROR_CODE_WUKONG_MODE = 16000009, 68 69 // not allowed for continuation flag. 70 ERROR_CODE_CONTINUATION_FLAG = 16000010, 71 72 // context is invalid. 73 ERROR_CODE_INVALID_CONTEXT = 16000011, 74 75 // application is controlled. 76 ERROR_CODE_CONTROLLED = 16000012, 77 78 // edm application is controlled. 79 ERROR_CODE_EDM_CONTROLLED = 16000013, 80 81 // ability wait start. 82 ERROR_START_ABILITY_WAITTING = 16000017, 83 84 // jump to other applicaiton is not enable after API12. 85 ERROR_CODE_NOT_SUPPORT_CROSS_APP_START = 16000018, 86 87 // implicit start can not match any component. 88 ERROR_CODE_CANNOT_MATCH_ANY_COMPONENT = 16000019, 89 90 // free install network abnormal. 91 ERROR_CODE_NETWORK_ABNORMAL = 16000051, 92 93 // not support free install. 94 ERROR_CODE_NOT_SUPPORT_FREE_INSTALL = 16000052, 95 96 // not top ability, not enable to free install. 97 ERROR_CODE_NOT_TOP_ABILITY = 16000053, 98 99 // too busy for free install. 100 ERROR_CODE_FREE_INSTALL_TOO_BUSY = 16000054, 101 102 // free install timeout. 103 ERROR_CODE_FREE_INSTALL_TIMEOUT = 16000055, 104 105 // free install other ability. 106 ERROR_CODE_FREE_INSTALL_OTHERS = 16000056, 107 108 // Cross-device installation-free is not supported. 109 ERROR_CODE_FREE_INSTALL_CROSS_DEVICE = 16000057, 110 111 // Uri flag invalid. 112 ERROR_CODE_INVALID_URI_FLAG = 16000058, 113 114 // Uri type invalid, only support file uri currently. 115 ERROR_CODE_INVALID_URI_TYPE = 16000059, 116 117 // Sandbox application can not grant URI permission. 118 ERROR_CODE_GRANT_URI_PERMISSION = 16000060, 119 120 // Operation not supported. 121 ERROR_CODE_OPERATION_NOT_SUPPORTED = 16000061, 122 123 // The number of child process exceeds upper bound. 124 ERROR_CODE_CHILD_PROCESS_NUMBER_EXCEEDS_UPPER_BOUND = 16000062, 125 126 // The target to restart does not belong to the current app or is not a UIAbility. 127 ERROR_CODE_RESTART_APP_INCORRECT_ABILITY = 16000063, 128 129 // Restart too frequently. Try again at least 3s later. 130 ERROR_CODE_RESTART_APP_FREQUENT = 16000064, 131 132 // ability not foreground. 133 ERROR_CODE_ABILITY_NOT_FOREGROUND = 16000065, 134 135 // wukong mode, can not move to foreground or background. 136 ERROR_CODE_WUKONG_MODE_CANT_MOVE_STATE = 16000066, 137 138 // Start options check failed. 139 ERROR_START_OPTIONS_CHECK_FAILED = 16000067, 140 141 // Ability already running. 142 ERROR_ABILITY_ALREADY_RUNNING = 16000068, 143 144 // extension start third party app has been controlled. 145 ERROR_CODE_EXTENSION_START_THIRD_PARTY_APP_CONTROLLED = 16000069, 146 147 // extension start service has been controlled. 148 ERROR_CODE_EXTENSION_START_SERVICE_CONTROLLED = 16000070, 149 150 // app is not Clone. 151 ERROR_NOT_APP_CLONE = 16000071, 152 153 // not support Clone app. 154 ERROR_CODE_MULTI_APP_NOT_SUPPORTED = 16000072, 155 156 // app clone index does not exist. 157 ERROR_APP_CLONE_INDEX_INVALID = 16000073, 158 159 // Caller does not exists. 160 ERROR_CODE_CALLER_NOT_EXIST = 16000074, 161 162 // Not support back to caller. 163 ERROR_CODE_NOT_SUPPROT_BACK_TO_CALLER = 16000075, 164 165 // The multi-instance is not supported. 166 ERROR_MULTI_INSTANCE_NOT_SUPPORTED = 16000078, 167 168 // Target application not found. 169 ERROR_CODE_GET_BUNFLE_INFO_FAILED = 16000081, 170 171 // invalid caller. 172 ERROR_CODE_INVALID_CALLER = 16200001, 173 174 // Setting permissions for resident processes 175 ERROR_CODE_NO_RESIDENT_PERMISSION = 16200006, 176 177 // no such mission id. 178 ERROR_CODE_NO_MISSION_ID = 16300001, 179 180 // no such mission listener. 181 ERROR_CODE_NO_MISSION_LISTENER = 16300002, 182 183 // not self application. 184 ERROR_NOT_SELF_APPLICATION = 16300003, 185 186 // observer not found. 187 ERROR_CODE_OBSERVER_NOT_FOUND = 16300004, 188 189 // target bundle not exist. 190 ERROR_CODE_TARGET_BUNDLE_NOT_EXIST = 16300005, 191 192 // target free install task does not exist. 193 ERROR_CODE_FREE_INSTALL_TASK_NOT_EXIST = 16300007, 194 195 ERROR_CODE_BUNDLE_NAME_INVALID = 18500001, 196 }; 197 198 std::string GetErrorMsg(const AbilityErrorCode& errCode); 199 std::string GetNoPermissionErrorMsg(const std::string& permission); 200 AbilityErrorCode GetJsErrorCodeByNativeError(int32_t errCode); 201 } // namespace AbilityRuntime 202 } // namespace OHOS 203 #endif