• 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 
16 #ifndef OHOS_ANI_ERROR_H
17 #define OHOS_ANI_ERROR_H
18 
19 #include <ani.h>
20 #include <string>
21 #include <unordered_map>
22 
23 namespace OHOS {
24 enum errorCode : int32_t {
25     PROXY_OR_REMOTE_OBJECT_INVALID_ERROR = 1900008,
26     WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR = 1900009,
27     READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR = 1900010,
28     CALL_JS_METHOD_ERROR = 1900012
29 };
30 
31 class AniError {
32 public:
33     AniError() = default;
34     static void ThrowError(ani_env *env, int errCode);
35 
36 private:
37     inline static const std::unordered_map<int32_t, std::string> aniErrMap_ {
38         {PROXY_OR_REMOTE_OBJECT_INVALID_ERROR, "proxy or remote object is invalid"},
39         {WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR, "write data to message sequence failed"},
40         {READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR, "read data from message sequence failed"},
41         {CALL_JS_METHOD_ERROR, "call js method failed"}
42     };
43 }; // AniError
44 } // namespace OHOS
45 #endif // OHOS_ANI_ERROR_H
46