1 /*
2 * Copyright (c) 2024 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 #include <unordered_map>
16
17 #include "error.h"
18
19 namespace OHOS {
20 namespace CJSystemapi {
21 namespace HiAppEvent {
22 using namespace OHOS::HiviewDFX::ErrorCode;
23
24 const std::unordered_map<int, int> ERR_MAP = {
25 { ERROR_INVALID_EVENT_NAME, ERR_INVALID_NAME },
26 { ERROR_INVALID_EVENT_DOMAIN, ERR_INVALID_DOMAIN },
27 { ERROR_HIAPPEVENT_DISABLE, ERR_DISABLE },
28 { ERROR_INVALID_PARAM_NAME, ERR_INVALID_KEY },
29 { ERROR_INVALID_PARAM_VALUE_LENGTH, ERR_INVALID_STR_LEN },
30 { ERROR_INVALID_PARAM_NUM, ERR_INVALID_PARAM_NUM },
31 { ERROR_INVALID_LIST_PARAM_SIZE, ERR_INVALID_ARR_LEN },
32 };
33
GetErrorCode(int errCode)34 int GetErrorCode(int errCode)
35 {
36 if (ERR_MAP.find(errCode) != ERR_MAP.end()) {
37 return ERR_MAP.at(errCode);
38 } else {
39 return ERR_PARAM;
40 }
41 }
42 } // HiAppEvent
43 } // CJSystemapi
44 } // OHOS