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 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 // no such systemcap. 37 ERROR_CODE_SYSTEMCAP = 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 // free install network abnormal. 85 ERROR_CODE_NETWORK_ABNORMAL = 16000051, 86 87 // not support free install. 88 ERROR_CODE_NOT_SUPPORT_FREE_INSTALL = 16000052, 89 90 // not top ability, not enable to free install. 91 ERROR_CODE_NOT_TOP_ABILITY = 16000053, 92 93 // too busy for free install. 94 ERROR_CODE_FREE_INSTALL_TOO_BUSY = 16000054, 95 96 // free install timeout. 97 ERROR_CODE_FREE_INSTALL_TIMEOUT = 16000055, 98 99 // free install other ability. 100 ERROR_CODE_FREE_INSTALL_OTHERS = 16000056, 101 102 // Cross-device installation-free is not supported. 103 ERROR_CODE_FREE_INSTALL_CROSS_DEVICE = 16000057, 104 105 // Uri flag invalid. 106 ERROR_CODE_INVALID_URI_FLAG = 16000058, 107 108 // Uri type invalid, only support file uri currently. 109 ERROR_CODE_INVALID_URI_TYPE = 16000059, 110 111 // Sandbox application can not grant URI permission. 112 ERROR_CODE_GRANT_URI_PERMISSION = 16000060, 113 114 // invalid caller. 115 ERROR_CODE_INVALID_CALLER = 16200001, 116 117 // no such mission id. 118 ERROR_CODE_NO_MISSION_ID = 16300001, 119 120 // no such mission listener. 121 ERROR_CODE_NO_MISSION_LISTENER = 16300002, 122 123 // not self application. 124 ERROR_NOT_SELF_APPLICATION = 16300003, 125 }; 126 127 std::string GetErrorMsg(const AbilityErrorCode& errCode); 128 std::string GetNoPermissionErrorMsg(const std::string& permission); 129 AbilityErrorCode GetJsErrorCodeByNativeError(int32_t errCode); 130 } // namespace AbilityRuntime 131 } // namespace OHOS 132 #endif