#ifdef __cplusplus
+#include <exception>
+#include <stdexcept>
+#include <string>
namespace tizen_media_audio {
-
-
/**
* Audio Error
*/
- class CAudioError {
+class CAudioError : public std::exception {
public:
/* Enums Definition */
enum class EError : unsigned int {
ERROR_INVALID_ARGUMENT,
ERROR_INVALID_HANDLE,
- ERROR_INVALID_SAMPLERATE,
- ERROR_INVALID_CHANNEL,
- ERROR_INVALID_FORMAT,
ERROR_INVALID_POINTER,
ERROR_INVALID_OPERATION,
ERROR_INVALID_STATE,
};
/* Constants Definition */
- static const unsigned int MSG_LENGTH = 512;
+ static constexpr auto MSG_LENGTH = 512;
/* Constructor & Destructor */
- CAudioError(EError err);
- CAudioError(EError err, const char* fileName, const char* parentFunc, int lineNum);
- CAudioError(EError err, const char* msg, const char* fileName, const char* parentFunc, int lineNum);
- //CAudioError(CAudioError& err);
- ~CAudioError();
-
- /* Static Methods */
- static EError getLastError();
- static const char* getLastErrorMsg();
-
- /* Setter & Getter */
- EError getError();
- const char* getErrorMsg();
-
- /* Overrided Operation */
- CAudioError& operator = (const EError err);
- CAudioError& operator = (const CAudioError& err);
- bool operator != (const EError err);
- bool operator == (const EError err);
- //friend bool operator == (const CAudioError& src, const EError& err);
-
- private:
- const char* __convertErrorToString(EError err);
-
- /* Members */
- static EError __mLastError;
- static char __mLastErrorMsg[MSG_LENGTH];
- EError __mError;
- char __mErrorMsg[MSG_LENGTH];
+ CAudioError(EError err, const char* msg, const char* file, const char* func, int line);
+ ~CAudioError() = default;
+
+ const char *what() const noexcept override {
+ return __mFullMsg.c_str();
+ }
+
+ const char* getErrorMsg() const noexcept;
+ const EError getError() const noexcept;
+
+private:
+ static const char* __convertErrorToString(EError err) noexcept;
+
+ EError __mError;
+ std::string __mMsg;
+ std::string __mFullMsg;
+
};
} /* namespace tizen_media_audio */
#endif
-#endif /* __TIZEN_MEDIA_CPP_OBJECTS_IO_H__ */
+#endif /* __TIZEN_MEDIA_AUDIO_IO_CAUDIOERROR_H__ */