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 
16 #include "startup_utils.h"
17 
18 #include <map>
19 
20 namespace OHOS {
21 namespace AbilityRuntime {
22 namespace {
23 const std::map<int32_t, std::string> ERR_MSG_MAP = {
24     { ERR_STARTUP_INVALID_VALUE,                    "invalid parameter." },
25     { ERR_STARTUP_INTERNAL_ERROR,                   "internal error." },
26     { ERR_STARTUP_DEPENDENCY_NOT_FOUND,             "startup task or its dependency not found." },
27     { ERR_STARTUP_CIRCULAR_DEPENDENCY,              "the startup tasks have circular dependencies." },
28     { ERR_STARTUP_FAILED_TO_EXECUTE_STARTUP,        "an error occurred while running the startup tasks." },
29     { ERR_STARTUP_TIMEOUT,                          "running startup tasks timeout." },
30 };
31 }
32 
GetErrorMessage(int32_t errCode)33 std::string StartupUtils::GetErrorMessage(int32_t errCode)
34 {
35     auto iter = ERR_MSG_MAP.find(errCode);
36     if (iter == ERR_MSG_MAP.end()) {
37         return ERR_MSG_MAP.at(ERR_STARTUP_INTERNAL_ERROR);
38     }
39     return iter->second;
40 }
41 } // namespace AbilityRuntime
42 } // namespace OHOS
43