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 { ERROR_INVALID_CUSTOM_PARAM_NUM, ERR_INVALID_CUSTOM_PARAM_NUM },
33 { ERROR_INVALID_PARAM_VALUE_LENGTH, ERR_INVALID_PARAM_VALUE_LENGTH}
34 };
35
GetErrorCode(int errCode)36 int GetErrorCode(int errCode)
37 {
38 if (ERR_MAP.find(errCode) != ERR_MAP.end()) {
39 return ERR_MAP.at(errCode);
40 } else {
41 return ERR_PARAM;
42 }
43 }
44 } // HiAppEvent
45 } // CJSystemapi
46 } // OHOS