fixup! Reset dump values when pause function is called
[platform/core/api/audio-io.git] / include / CAudioError.h
index de1e1fb..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:
-        /* Constants Definition */
-        static const unsigned int MSG_LENGTH = 512;
-
-        enum EError {
+        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,
+            ERROR_NOT_SUPPORTED_TYPE,
 
             ERROR_PERMISSION_DENIED,
 
+            ERROR_DEVICE_POLICY_RESTRICTION,
             ERROR_DEVICE_NOT_OPENED,
             ERROR_DEVICE_NOT_CLOSED,
 
@@ -62,41 +60,22 @@ namespace tizen_media_audio {
             ERROR_MAX
         };
 
-    private:
-        /* Members */
-        static EError mLastError;
-        static char   mLastErrorMsg[MSG_LENGTH];
+        static constexpr auto MSG_LENGTH = 512;
+        CAudioError(EError err, const char* msg, const char* file, const char* func, int line);
 
-        EError        mError;
-        char          mErrorMsg[MSG_LENGTH];
+        const char *what() const noexcept override;
+        const char* getErrorMsg() const noexcept;
+        EError getError() const noexcept;
 
-        const char* _convertErrorToString(EError err);
+private:
+        static const char* __convertErrorToString(EError err) noexcept;
 
-    public:
-        /* 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);
+        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__ */