1 /* 2 * Copyright (c) 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_ETS_ERROR_UTILS_H 17 #define OHOS_ABILITY_RUNTIME_ETS_ERROR_UTILS_H 18 19 #include "ability_business_error.h" 20 #include "ani.h" 21 22 namespace OHOS { 23 namespace AbilityRuntime { 24 25 class EtsErrorUtil { 26 public: 27 static void ThrowError(ani_env *env, ani_object err); 28 static void ThrowError(ani_env *env, int32_t errCode, const std::string &errorMsg = ""); 29 static void ThrowError(ani_env *env, const AbilityErrorCode &err); 30 static void ThrowInvalidCallerError(ani_env *env); 31 static void ThrowTooFewParametersError(ani_env *env); 32 static void ThrowInvalidNumParametersError(ani_env *env); 33 static void ThrowNoPermissionError(ani_env *env, const std::string &permission); 34 static void ThrowInvalidParamError(ani_env *env, const std::string &message); 35 static void ThrowErrorByNativeErr(ani_env *env, int32_t err); 36 static void ThrowNotSystemAppError(ani_env *env); 37 static void ThrowEtsTransferClassError(ani_env *env); 38 39 static ani_object CreateError(ani_env *env, const AbilityErrorCode &err); 40 static ani_object CreateError(ani_env *env, ani_int code, const std::string &msg); 41 static ani_object CreateInvalidParamError(ani_env *env, const std::string &message); 42 static ani_object CreateNoPermissionError(ani_env *env, const std::string &permission); 43 static ani_object CreateErrorByNativeErr(ani_env *env, int32_t err, const std::string &permission = ""); 44 static ani_object WrapError(ani_env *env, const std::string &msg); 45 }; 46 } // namespace AbilityRuntime 47 } // namespace OHOS 48 #endif // OHOS_ABILITY_RUNTIME_ETS_ERROR_UTILS_H 49