fixup! Reset dump values when pause function is called
[platform/core/api/audio-io.git] / include / CAudioError.h
index e683c6c..3c6bf7c 100644 (file)
 
 #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_NONE,
 
             ERROR_INVALID_ARGUMENT,
             ERROR_INVALID_HANDLE,
-            ERROR_INVALID_SAMPLERATE,
-            ERROR_INVALID_CHANNEL,
-            ERROR_INVALID_FORMAT,
             ERROR_INVALID_POINTER,
             ERROR_INVALID_OPERATION,
+            ERROR_INVALID_STATE,
 
             ERROR_NOT_INITIALIZED,
             ERROR_NOT_SUPPORTED,
@@ -62,43 +60,22 @@ namespace tizen_media_audio {
             ERROR_MAX
         };
 
-        /* Constants Definition */
-        static const unsigned int 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];
+        static constexpr auto MSG_LENGTH = 512;
+        CAudioError(EError err, const char* msg, const char* file, const char* func, int line);
+
+        const char *what() const noexcept override;
+        const char* getErrorMsg() const noexcept;
+        EError getError() const noexcept;
+
+private:
+        static const char* __convertErrorToString(EError err) noexcept;
+
+        EError __mError;
+        std::runtime_error __mFullMsg;
     };
 
 
 } /* namespace tizen_media_audio */
 
 #endif
-#endif /* __TIZEN_MEDIA_CPP_OBJECTS_IO_H__ */
+#endif /* __TIZEN_MEDIA_AUDIO_IO_CAUDIOERROR_H__ */