b508fe80032d5a81f41aa0f60fdc2f83305b4950
[platform/core/api/audio-io.git] / include / CAudioError.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef __TIZEN_MEDIA_AUDIO_IO_CAUDIOERROR_H__
18 #define __TIZEN_MEDIA_AUDIO_IO_CAUDIOERROR_H__
19
20
21 #ifdef __cplusplus
22
23 #include <exception>
24 #include <stdexcept>
25 #include <string>
26
27 namespace tizen_media_audio {
28     /**
29      * Audio Error
30      */
31 class CAudioError : public std::exception {
32     public:
33         /* Enums Definition */
34         enum class EError : unsigned int {
35             ERROR_NONE,
36
37             ERROR_INVALID_ARGUMENT,
38             ERROR_INVALID_HANDLE,
39             ERROR_INVALID_POINTER,
40             ERROR_INVALID_OPERATION,
41             ERROR_INVALID_STATE,
42
43             ERROR_NOT_INITIALIZED,
44             ERROR_NOT_SUPPORTED,
45             ERROR_NOT_SUPPORTED_TYPE,
46
47             ERROR_PERMISSION_DENIED,
48
49             ERROR_DEVICE_POLICY_RESTRICTION,
50             ERROR_DEVICE_NOT_OPENED,
51             ERROR_DEVICE_NOT_CLOSED,
52
53             ERROR_OUT_OF_MEMORY,
54             ERROR_INTERNAL_OPERATION,
55             ERROR_FAILED_OPERATION,
56
57             ERROR_POLICY_BLOCKED,
58             ERROR_POLICY_INTERRUPTED,
59             ERROR_POLICY_DUPLICATED,
60
61             ERROR_MAX
62         };
63
64         /* Constants Definition */
65         static const unsigned int MSG_LENGTH = 512;
66
67         /* Constructor & Destructor */
68         explicit CAudioError(EError err);
69         CAudioError(EError err, const char* msg, const char* file, const char* func, int line);
70         ~CAudioError() = default;
71
72         const char *what() const noexcept override {
73             return __mFullMsg.c_str();
74         }
75
76         const char* getErrorMsg() const noexcept;
77         const EError getError() const noexcept;
78
79 private:
80         static const char* __convertErrorToString(EError err) noexcept;
81
82         EError __mError;
83         std::string __mMsg;
84         std::string __mFullMsg;
85
86     };
87
88
89 } /* namespace tizen_media_audio */
90
91 #endif
92 #endif /* __TIZEN_MEDIA_AUDIO_IO_CAUDIOERROR_H__ */