• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef ANI_RDB_ERROR_H
16 #define ANI_RDB_ERROR_H
17 
18 #include <map>
19 #include <optional>
20 #include <string>
21 #include <ani.h>
22 #include "logger.h"
23 #include "rdb_errno.h"
24 
25 namespace OHOS {
26 namespace RelationalStoreAniKit {
27 constexpr int MAX_INPUT_COUNT = 10;
28 constexpr int OK = 0;
29 constexpr int ERR = -1;
30 
31 constexpr int E_NON_SYSTEM_APP_ERROR = 202;
32 constexpr int E_PARAM_ERROR = 401;
33 constexpr int E_INNER_ERROR = 14800000;
34 constexpr int E_NOT_STAGE_MODE = 14801001;
35 constexpr int E_DATA_GROUP_ID_INVALID = 14801002;
36 
37 struct JsErrorCode {
38     int32_t status;
39     int32_t jsCode;
40     const char *message;
41 };
42 const std::optional<JsErrorCode> GetJsErrorCode(int32_t errorCode);
43 ani_object GetAniBusinessError(ani_env *env, int32_t errorCode);
44 void ThrowBusinessError(ani_env *env, int32_t status);
45 void ThrowBusinessError(ani_env *env, int32_t status, std::string message);
46 
47 } // namespace RelationalStoreAniKit
48 } // namespace OHOS
49 
50 #endif // ANI_RDB_ERROR_H
51 
52