• 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 BASE_NOTIFICATION_COMMON_EVENT_MANAGER_INCLUDE_ANI_COMMON_EVENT_ERROR_H
17 #define BASE_NOTIFICATION_COMMON_EVENT_MANAGER_INCLUDE_ANI_COMMON_EVENT_ERROR_H
18 
19 #include <string>
20 #include <vector>
21 #include "ces_inner_error_code.h"
22 #include "event_log_wrapper.h"
23 
24 namespace OHOS {
25 namespace EventManagerFwkAni {
26 static const std::unordered_map<int32_t, std::string> ERROR_CODE_TO_MESSAGE {
27     {Notification::ERR_NOTIFICATION_CES_COMMON_PERMISSION_DENIED,
28         "The application dose not have permission to call the interface"},
29     {Notification::ERR_NOTIFICATION_CES_COMMON_NOT_SYSTEM_APP, "The application is not system application"},
30     {Notification::ERR_NOTIFICATION_CES_COMMON_PARAM_INVALID, "The param input is invalid"},
31     {Notification::ERR_NOTIFICATION_CES_COMMON_SYSTEMCAP_NOT_SUPPORT, "The want action send by event is null"},
32     {Notification::ERR_NOTIFICATION_CES_SANDBOX_NOT_SUPPORT, "The sandbox application can not send common event"},
33     {Notification::ERR_NOTIFICATION_CES_WANT_ACTION_IS_NULL, "The want action send by event is null"},
34     {Notification::ERR_NOTIFICATION_CES_EVENT_FREQ_TOO_HIGH, "The common event send frequency too high"},
35     {Notification::ERR_NOTIFICATION_CES_NOT_SA_SYSTEM_APP,
36         "The application can not send common event, it may be not SA app or System app"},
37     {Notification::ERR_NOTIFICATION_CES_NO_SUBSCRIBER, "The subscriber can not found"},
38     {Notification::ERR_NOTIFICATION_CES_USERID_INVALID, "he usreId is invalid"},
39     {Notification::ERR_NOTIFICATION_SEND_ERROR, "The message send error"},
40     {Notification::ERR_NOTIFICATION_CESM_ERROR, "The CEMS error"},
41     {Notification::ERR_NOTIFICATION_SYS_ERROR, "The system error"},
42 };
43 
FindCesErrMsg(const int32_t errCode)44 inline std::string FindCesErrMsg(const int32_t errCode)
45 {
46     auto findMsg = ERROR_CODE_TO_MESSAGE.find(errCode);
47     if (findMsg == ERROR_CODE_TO_MESSAGE.end()) {
48         EVENT_LOGE("FindCesErrMsg Inner error.");
49         return "Inner error.";
50     }
51     return findMsg->second;
52 }
53 
54 } // namespace EventManagerFwkAni
55 } // OHOS
56 #endif // BASE_NOTIFICATION_COMMON_EVENT_MANAGER_INCLUDE_ANI_COMMON_EVENT_ERROR_H