1 /*
2  * Copyright (c) 2022-2022 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 "pipeline/core/error_code.h"
16 #include <map>
17 
18 namespace OHOS {
19 namespace Media {
20 static const std::map<ErrorCode, const char*> g_ErrorTypeMap = {
21     {ErrorCode::END_OF_STREAM,  "END_OF_STREAM"},
22     {ErrorCode::SUCCESS,    "SUCCESS"},
23     {ErrorCode::ERROR_UNKNOWN,  "ERROR_UNKNOWN"},
24     {ErrorCode::ERROR_UNIMPLEMENTED,    "ERROR_UNIMPLEMENTED"},
25     {ErrorCode::ERROR_AGAIN,    "ERROR_AGAIN"},
26     {ErrorCode::ERROR_INVALID_PARAMETER_VALUE,   "ERROR_INVALID_PARAMETER_VALUE"},
27     {ErrorCode::ERROR_INVALID_PARAMETER_TYPE,     "ERROR_INVALID_PARAMETER_TYPE"},
28     {ErrorCode::ERROR_INVALID_OPERATION,    "ERROR_INVALID_OPERATION"},
29     {ErrorCode::ERROR_UNSUPPORTED_FORMAT,   "ERROR_UNSUPPORTED_FORMAT"},
30     {ErrorCode::ERROR_NOT_EXISTED,  "ERROR_NOT_EXISTED"},
31     {ErrorCode::ERROR_TIMED_OUT,    "ERROR_TIMED_OUT"},
32     {ErrorCode::ERROR_NO_MEMORY,    "ERROR_NO_MEMORY"},
33     {ErrorCode::ERROR_INVALID_STATE,    "ERROR_INVALID_STATE"},
34     {ErrorCode::ERROR_PERMISSION_DENIED,    "ERROR_PERMISSION_DENIED"}
35 };
36 
GetErrorName(ErrorCode code)37 const char* GetErrorName(ErrorCode code)
38 {
39     auto it = g_ErrorTypeMap.find(code);
40     if (it!= g_ErrorTypeMap.end()) {
41         return it->second;
42     }
43     return "Unknow error type";
44 }
45 }
46 }