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_PARAM_ILLEGAL = 401, 30 JS_ERROR_SYSTEM_CAPABILITY_NOT_SUPPORT = 801, 31 JS_ERROR_PARAM_INVALID = 12100001, 32 JS_ERROR_TOKENID_NOT_EXIST, 33 JS_ERROR_PERMISSION_NOT_EXIST, 34 JS_ERROR_NOT_USE_TOGETHER, 35 JS_ERROR_REGISTERS_EXCEED_LIMITATION, 36 JS_ERROR_PERMISSION_OPERATION_NOT_ALLOWED, 37 JS_ERROR_SERVICE_NOT_RUNNING, 38 JS_ERROR_OUT_OF_MEMORY, 39 JS_ERROR_INNER, 40 } JsErrorCode; 41 42 std::string GetParamErrorMsg(const std::string& param, const std::string& type); 43 napi_value GenerateBusinessError(napi_env env, int32_t errCode, const std::string& errMsg); 44 std::string GetErrorMessage(uint32_t errCode); 45 napi_value GetNapiNull(napi_env env); 46 } // namespace AccessToken 47 } // namespace Security 48 } // namespace OHOS 49 #endif /* INTERFACES_PRIVACY_KITS_NAPI_ERROR_H */ 50 51