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#ifndef ERROR_UTIL_H 16#define ERROR_UTIL_H 17 18#include <string> 19 20#include "napi/native_api.h" 21#include "napi/native_node_api.h" 22 23namespace OHOS { 24namespace Global { 25namespace I18n { 26// Common error code 27const int32_t I18N_NO_PERMISSION = 201; // The app don't have requested permission 28const int32_t I18N_NOT_SYSTEM_APP = 202; // The app isn't a system app 29const int32_t I18N_NOT_FOUND = 401; // Input parameter is missing 30 31// I18N error code 32const int32_t I18N_NOT_VALID = 890001; // Unspported para value 33const int32_t I18N_OPTION_NOT_VALID = 890002; // Unspported option value 34const size_t FUNC_ARGS_COUNT = 2; // Function input parameter count 35 36class ErrorUtil { 37public: 38 static void NapiThrow(napi_env env, int32_t errCode, const std::string& valueName, 39 const std::string& valueContent, bool throwError); 40}; 41} // namespace I18n 42} // namespace Global 43} // namespace OHOS 44#endif