2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "CAudioIODef.h"
23 using namespace tizen_media_audio;
28 CAudioError::CAudioError(EError err, const char* msg, const char* file, const char* func, int line) :
31 char __mErrorMsg[MSG_LENGTH] = { 0, };
33 snprintf(__mErrorMsg, MSG_LENGTH, "[%s|%s|%s(%d)|"
34 COLOR_CYAN "%s" COLOR_END "]",
35 __convertErrorToString(__mError), file, func, line, msg);
37 __mFullMsg = std::runtime_error{__mErrorMsg};
40 const char *CAudioError::what() const noexcept {
41 return __mFullMsg.what();
44 const char* CAudioError::getErrorMsg() const noexcept {
48 CAudioError::EError CAudioError::getError() const noexcept {
52 const char* CAudioError::__convertErrorToString(EError err) noexcept {
55 case EError::ERROR_NONE: return COLOR_GREEN "ERROR_NONE" COLOR_END;
56 case EError::ERROR_INVALID_ARGUMENT: return COLOR_RED "ERROR_INVALID_ARGUMENT" COLOR_END;
58 case EError::ERROR_INVALID_HANDLE: return COLOR_RED "ERROR_INVALID_HANDLE" COLOR_END;
59 case EError::ERROR_INVALID_POINTER: return COLOR_RED "ERROR_INVALID_POINTER" COLOR_END;
61 case EError::ERROR_INVALID_OPERATION: return COLOR_RED "ERROR_INVALID_OPERATION" COLOR_END;
62 case EError::ERROR_INVALID_STATE: return COLOR_RED "ERROR_INVALID_STATE" COLOR_END;
63 case EError::ERROR_NOT_INITIALIZED: return COLOR_RED "ERROR_NOT_INITIALIZED" COLOR_END;
64 case EError::ERROR_NOT_SUPPORTED: return COLOR_RED "ERROR_NOT_SUPPORTED" COLOR_END;
65 case EError::ERROR_NOT_SUPPORTED_TYPE: return COLOR_RED "ERROR_NOT_SUPPORTED_TYPE" COLOR_END;
67 case EError::ERROR_PERMISSION_DENIED: return COLOR_RED "ERROR_PERMISSION_DENIED" COLOR_END;
68 case EError::ERROR_DEVICE_POLICY_RESTRICTION: return COLOR_RED "ERROR_DEVICE_POLICY_RESTRICTION" COLOR_END;
69 case EError::ERROR_DEVICE_NOT_OPENED: return COLOR_RED "ERROR_DEVICE_NOT_OPENED" COLOR_END;
70 case EError::ERROR_DEVICE_NOT_CLOSED: return COLOR_RED "ERROR_DEVICE_NOT_CLOSED" COLOR_END;
71 case EError::ERROR_OUT_OF_MEMORY: return COLOR_RED "ERROR_OUT_OF_MEMORY" COLOR_END;
72 case EError::ERROR_INTERNAL_OPERATION: return COLOR_RED "ERROR_INTERNAL_OPERATION" COLOR_END;
73 case EError::ERROR_FAILED_OPERATION: return COLOR_RED "ERROR_FAILED_OPERATION" COLOR_END;
74 case EError::ERROR_POLICY_BLOCKED: return COLOR_RED "ERROR_POLICY_BLOCKED" COLOR_END;
75 case EError::ERROR_POLICY_INTERRUPTED: return COLOR_RED "ERROR_POLICY_INTERRUPTED" COLOR_END;
76 case EError::ERROR_POLICY_DUPLICATED: return COLOR_RED "ERROR_POLICY_DUPLICATED" COLOR_END;