• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2025 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     // the context is not ability context.
91     ERR_ABILITY_RUNTIME_EXTERNAL_NOT_ABILITY_CONTEXT = 16000020,
92 
93     // free install network abnormal.
94     ERROR_CODE_NETWORK_ABNORMAL = 16000051,
95 
96     // not support free install.
97     ERROR_CODE_NOT_SUPPORT_FREE_INSTALL = 16000052,
98 
99     // not top ability, not enable to free install.
100     ERROR_CODE_NOT_TOP_ABILITY = 16000053,
101 
102     // too busy for free install.
103     ERROR_CODE_FREE_INSTALL_TOO_BUSY = 16000054,
104 
105     // free install timeout.
106     ERROR_CODE_FREE_INSTALL_TIMEOUT = 16000055,
107 
108     // free install other ability.
109     ERROR_CODE_FREE_INSTALL_OTHERS = 16000056,
110 
111     // Cross-device installation-free is not supported.
112     ERROR_CODE_FREE_INSTALL_CROSS_DEVICE = 16000057,
113 
114     // Uri flag invalid.
115     ERROR_CODE_INVALID_URI_FLAG = 16000058,
116 
117     // Uri type invalid, only support file uri currently.
118     ERROR_CODE_INVALID_URI_TYPE = 16000059,
119 
120     // Sandbox application can not grant URI permission.
121     ERROR_CODE_GRANT_URI_PERMISSION = 16000060,
122 
123     // Operation not supported.
124     ERROR_CODE_OPERATION_NOT_SUPPORTED = 16000061,
125 
126     // The number of child process exceeds upper bound.
127     ERROR_CODE_CHILD_PROCESS_NUMBER_EXCEEDS_UPPER_BOUND = 16000062,
128 
129     // The target to restart does not belong to the current app or is not a UIAbility.
130     ERROR_CODE_RESTART_APP_INCORRECT_ABILITY = 16000063,
131 
132     // Restart too frequently. Try again at least 3s later.
133     ERROR_CODE_RESTART_APP_FREQUENT = 16000064,
134 
135     // ability not foreground.
136     ERROR_CODE_ABILITY_NOT_FOREGROUND = 16000065,
137 
138     // wukong mode, can not move to foreground or background.
139     ERROR_CODE_WUKONG_MODE_CANT_MOVE_STATE = 16000066,
140 
141     // Start options check failed.
142     ERROR_START_OPTIONS_CHECK_FAILED = 16000067,
143 
144     // Ability already running.
145     ERROR_ABILITY_ALREADY_RUNNING = 16000068,
146 
147     // extension start third party app has been controlled.
148     ERROR_CODE_EXTENSION_START_THIRD_PARTY_APP_CONTROLLED = 16000069,
149 
150     // extension start service has been controlled.
151     ERROR_CODE_EXTENSION_START_SERVICE_CONTROLLED = 16000070,
152 
153     // app is not Clone.
154     ERROR_NOT_APP_CLONE = 16000071,
155 
156     // not support Clone app.
157     ERROR_CODE_MULTI_APP_NOT_SUPPORTED = 16000072,
158 
159     // app clone index does not exist.
160     ERROR_APP_CLONE_INDEX_INVALID = 16000073,
161 
162     // Caller does not exists.
163     ERROR_CODE_CALLER_NOT_EXIST = 16000074,
164 
165     // Not support back to caller.
166     ERROR_CODE_NOT_SUPPROT_BACK_TO_CALLER = 16000075,
167 
168     // invalid app instance key.
169     ERROR_CODE_INVALID_APP_INSTANCE_KEY = 16000076,
170 
171     // upper limit.
172     ERROR_CODE_UPPER_LIMIT = 16000077,
173 
174     // The multi-instance is not supported.
175     ERROR_MULTI_INSTANCE_NOT_SUPPORTED = 16000078,
176 
177     // APP_INSTANCE_KEY cannot be specified.
178     ERROR_CODE_APP_INSTANCE_KEY_NOT_SUPPORT = 16000079,
179 
180     // Not support to create a new instance.
181     ERROR_CODE_CREATE_NEW_INSTANCE_NOT_SUPPORT = 16000080,
182 
183     // Target application not found.
184     ERROR_CODE_GET_APPLICATION_INFO_FAILED = 16000081,
185 
186     // UIAbility is in starting state.
187     ERROR_CODE_UI_ABILITY_IS_STARTING = 16000082,
188 
189     // extension can not start the ability due to extension control.
190     ERROR_CODE_EXTENSION_START_ABILITY_CONTROLLED = 16000083,
191 
192     // Only allow DelegatorAbility to call the method once.
193     ERROR_CODE_NOT_HOOK = 16000084,
194 
195     // The interaction process between Ability and the Window encountered an error.
196     ERROR_CODE_FROM_WINDOW = 16000085,
197 
198     ERR_CODE_GET_FILE_URIS_BY_KEY_FAILED = 16000091,
199 
200     ERR_CODE_NO_PERMISSION_GRANT_URI = 16000092,
201 
202     ERR_CODE_INVALID_CALLER_TOKENID = 16000093,
203 
204     ERR_CODE_INVALID_TARGET_TOKENID = 16000094,
205 
206     // the target not in app identifier allow list.
207     ERROR_CODE_TARGET_NOT_IN_APP_IDENTIFIER_ALLOW_LIST = 16000200,
208 
209     // the target has not been started yet.
210     ERROR_CODE_TARGET_NOT_STARTED = 16000201,
211 
212     // The context is not UIAbilityContext.
213     ERROR_CODE_NOT_UI_ABILITY_CONTEXT = 16000086,
214 
215     // The caller is not an atomic service.
216     ERROR_CODE_CALLER_NOT_ATOMIC_SERVICE = 16000090,
217 
218     // invalid caller.
219     ERROR_CODE_INVALID_CALLER = 16200001,
220 
221     // Setting permissions for resident processes
222     ERROR_CODE_NO_RESIDENT_PERMISSION = 16200006,
223 
224     // no such mission id.
225     ERROR_CODE_NO_MISSION_ID = 16300001,
226 
227     // no such mission listener.
228     ERROR_CODE_NO_MISSION_LISTENER = 16300002,
229 
230     // not self application.
231     ERROR_NOT_SELF_APPLICATION = 16300003,
232 
233     // observer not found.
234     ERROR_CODE_OBSERVER_NOT_FOUND = 16300004,
235 
236     // target bundle not exist.
237     ERROR_CODE_TARGET_BUNDLE_NOT_EXIST = 16300005,
238 
239     // target free install task does not exist.
240     ERROR_CODE_FREE_INSTALL_TASK_NOT_EXIST = 16300007,
241 
242     // target bundle has no main ability.
243     ERROR_CODE_NO_MAIN_ABILITY = 16300008,
244 
245     // target application has no status-bar ability.
246     ERROR_CODE_NO_STATUS_BAR_ABILITY = 16300009,
247 
248     // target application is not attached to a status bar.
249     ERROR_CODE_NOT_ATTACHED_TO_STATUS_BAR = 16300010,
250 
251     // invalid main element type
252     ERROR_CODE_INVALID_MAIN_ELEMENT_TYPE = 16000202,
253 
254     // can not change keep alive status
255     ERROR_CODE_CHANGE_KEEP_ALIVE = 16000203,
256 
257     ERROR_CODE_KIOSK_MODE_NOT_IN_WHITELIST = 16000110,
258 
259     ERROR_CODE_ALREADY_IN_KIOSK_MODE = 16000111,
260 
261     ERROR_CODE_NOT_IN_KIOSK_MODE = 16000112,
262 
263     ERROR_CODE_APP_NOT_IN_FOCUS = 16000113,
264 
265     ERROR_CODE_NOT_ISOLATION_PROCESS = 16000115,
266 
267     ERROR_CODE_ALREADY_MASTER_PROCESS = 16000116,
268 
269     ERROR_CODE_NOT_CANDIDATE_MASTER_PROCESS = 16000117,
270 
271     ERROR_CODE_EXCEEDS_WANT_LIST_MAXIMUM_SIZE = 16000120,
272 
273     ERROR_CODE_TARGET_TYPE_NOT_UI_ABILITY = 16000121,
274 
275     ERROR_CODE_TARGET_BLOCKED_BY_SYSTEM_MODULE = 16000122,
276 
277     ERROR_CODE_NOT_SUPPORT_IMPLICIT_START = 16000123,
278 
279     ERROR_CODE_NOT_SUPPORT_START_REMOTE_UI_ABILITY = 16000124,
280 
281     ERROR_CODE_NOT_SUPPORT_START_PLUGIN_UI_ABILITY = 16000125,
282 
283     ERROR_CODE_NOT_SUPPORT_START_DLP_FILES = 16000126,
284 
285     ERROR_CODE_MAIN_WINDOW_NOT_EXIST = 16000135,
286 
287     // target bundle is not in u1
288     ERROR_CODE_NO_U1 = 16000204,
289 
290     ERROR_CODE_BUNDLE_NAME_INVALID = 18500001,
291 };
292 
293 std::string GetErrorMsg(const AbilityErrorCode& errCode);
294 std::string GetNoPermissionErrorMsg(const std::string& permission);
295 AbilityErrorCode GetJsErrorCodeByNativeError(int32_t errCode);
296 }  // namespace AbilityRuntime
297 }  // namespace OHOS
298 #endif
299