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  INTERFACES_PRIVACY_KITS_NAPI_ERROR_H
17 #define  INTERFACES_PRIVACY_KITS_NAPI_ERROR_H
18 #include "string"
19 #include "access_token.h"
20 #include "napi/native_api.h"
21 #include "napi/native_node_api.h"
22 
23 namespace OHOS {
24 namespace Security {
25 namespace AccessToken {
26 typedef enum {
27     JS_OK = 0,
28     JS_ERROR_PERMISSION_DENIED = 201,
29     JS_ERROR_NOT_SYSTEM_APP = 202,
30     JS_ERROR_PARAM_ILLEGAL = 401,
31     JS_ERROR_SYSTEM_CAPABILITY_NOT_SUPPORT = 801,
32     JS_ERROR_START_ABILITY_FAIL = 1011,
33     JS_ERROR_BACKGROUND_FAIL = 1012,
34     JS_ERROR_TERMINATE_FAIL = 1013,
35     JS_ERROR_PARAM_INVALID = 12100001,
36     JS_ERROR_TOKENID_NOT_EXIST,
37     JS_ERROR_PERMISSION_NOT_EXIST,
38     JS_ERROR_NOT_USE_TOGETHER,
39     JS_ERROR_REGISTERS_EXCEED_LIMITATION,
40     JS_ERROR_PERMISSION_OPERATION_NOT_ALLOWED,
41     JS_ERROR_SERVICE_NOT_RUNNING,
42     JS_ERROR_OUT_OF_MEMORY,
43     JS_ERROR_INNER,
44     JS_ERROR_REQUEST_IS_ALREADY_EXIST = 12100010,
45     JS_ERROR_ALL_PERM_GRANTED = 12100011,
46     JS_ERROR_PERM_REVOKE_BY_USER = 12100012,
47     JS_ERROR_GLOBAL_SWITCH_IS_ALREADY_OPEN = 12100013,
48 } JsErrorCode;
49 
50 std::string GetParamErrorMsg(const std::string& param, const std::string& type);
51 napi_value GenerateBusinessError(napi_env env, int32_t errCode, const std::string& errMsg);
52 std::string GetErrorMessage(uint32_t errCode);
53 napi_value GetNapiNull(napi_env env);
54 }  // namespace AccessToken
55 }  // namespace Security
56 }  // namespace OHOS
57 #endif /* INTERFACES_PRIVACY_KITS_NAPI_ERROR_H */
58 
59