e6c98ebdbe5baf7512d3be5ee45fd79bde9dac94
[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 constexpr unsigned int MSG_LENGTH = 512;
66
67         /* Constructor & Destructor */
68         CAudioError(EError err, const char* msg, const char* file, const char* func, int line);
69         ~CAudioError() = default;
70
71         const char *what() const noexcept override {
72             return __mFullMsg.c_str();
73         }
74
75         const char* getErrorMsg() const noexcept;
76         const EError getError() const noexcept;
77
78 private:
79         static const char* __convertErrorToString(EError err) noexcept;
80
81         EError __mError;
82         std::string __mMsg;
83         std::string __mFullMsg;
84
85     };
86
87
88 } /* namespace tizen_media_audio */
89
90 #endif
91 #endif /* __TIZEN_MEDIA_AUDIO_IO_CAUDIOERROR_H__ */