Derive RtAudioError from std::runtime_error
[rtaudio-cdist.git] / RtAudio.h
index d7fefa3e53a2ab3d50309f7679c343e8ebce606a..207de8cdf8957e1b02f10b827db2e71dd1b0dc08 100644 (file)
--- a/RtAudio.h
+++ b/RtAudio.h
@@ -49,7 +49,7 @@
 
 #include <string>
 #include <vector>
-#include <exception>
+#include <stdexcept>
 #include <iostream>
 
 /*! \typedef typedef unsigned long RtAudioFormat;
@@ -195,7 +195,7 @@ typedef int (*RtAudioCallback)( void *outputBuffer, void *inputBuffer,
 */
 /************************************************************************/
 
-class RtAudioError : public std::exception
+class RtAudioError : public std::runtime_error
 {
  public:
   //! Defined RtAudioError types.
@@ -214,25 +214,22 @@ class RtAudioError : public std::exception
   };
 
   //! The constructor.
-  RtAudioError( const std::string& message, Type type = RtAudioError::UNSPECIFIED )  : message_(message), type_(type) {}
-  //! The destructor.
-  virtual ~RtAudioError( void ) {}
+  RtAudioError( const std::string& message,
+                Type type = RtAudioError::UNSPECIFIED )
+    : std::runtime_error(message), type_(type) {}
 
   //! Prints thrown error message to stderr.
-  virtual void printMessage( void ) const { std::cerr << '\n' << message_ << "\n\n"; }
+  virtual void printMessage( void ) const
+    { std::cerr << '\n' << what() << "\n\n"; }
 
   //! Returns the thrown error message type.
   virtual const Type& getType(void) const { return type_; }
 
   //! Returns the thrown error message string.
-  virtual const std::string& getMessage(void) const { return message_; }
-
-  //! Returns the thrown error message as a c-style string.
-  virtual const char* what( void ) const { return message_.c_str(); }
+  virtual const std::string getMessage(void) const
+    { return std::string(what()); }
 
  protected:
-  std::string message_;
   Type type_;
 };
 
@@ -616,7 +613,7 @@ struct CallbackInfo {
 
   // Default constructor.
   CallbackInfo()
-  :object(0), callback(0), userData(0), errorCallback(0), apiInfo(0), isRunning(false), doRealtime(false) {}
+  :object(0), callback(0), userData(0), errorCallback(0), apiInfo(0), isRunning(false), doRealtime(false), priority(0) {}
 };
 
 // **************************************************************** //