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 "error_code.h"
17 
18 #include <map>
19 
20 namespace OHOS {
21 namespace Media {
22 namespace Effect {
23 static const std::map<ErrorCode, const char*> g_ErrorTypeMap = {
24     {ErrorCode::SUCCESS, "SUCCESS"},
25     {ErrorCode::ERR_UNKNOWN, "ERROR_UNKNOWN"},
26     {ErrorCode::ERR_UNIMPLEMENTED, "ERROR_UNIMPLEMENTED"},
27     {ErrorCode::ERR_INVALID_PARAMETER_VALUE, "ERROR_INVALID_PARAMETER_VALUE"},
28     {ErrorCode::ERR_INVALID_PARAMETER_TYPE, "ERROR_INVALID_PARAMETER_TYPE"},
29     {ErrorCode::ERR_INVALID_OPERATION, "ERROR_INVALID_OPERATION"},
30     {ErrorCode::ERR_TIMED_OUT, "ERROR_TIMED_OUT"},
31     {ErrorCode::ERR_NO_MEMORY, "ERROR_NO_MEMORY"},
32     {ErrorCode::ERR_PERMISSION_DENIED, "ERROR_PERMISSION_DENIED"}
33 };
34 
GetErrorName(ErrorCode code)35 std::string GetErrorName(ErrorCode code)
36 {
37     auto it = g_ErrorTypeMap.find(code);
38     if (it != g_ErrorTypeMap.end()) {
39         return std::string(it->second);
40     }
41     return "Unknow error type";
42 }
43 } // namespace Effect
44 } // namespace Media
45 } // namespace OHOS