1 /************************************************************************/
3 \brief Exception handling class for RtAudio & RtMidi.
5 The RtError class is quite simple but it does allow errors to be
6 "caught" by RtError::Type. See the RtAudio and RtMidi
7 documentation to know which methods can throw an RtError.
10 /************************************************************************/
21 //! Defined RtError types.
23 WARNING, /*!< A non-critical error. */
24 DEBUG_WARNING, /*!< A non-critical error which might be useful for debugging. */
25 UNSPECIFIED, /*!< The default, unspecified error type. */
26 NO_DEVICES_FOUND, /*!< No devices found on system. */
27 INVALID_DEVICE, /*!< An invalid device ID was specified. */
28 INVALID_STREAM, /*!< An invalid stream ID was specified. */
29 MEMORY_ERROR, /*!< An error occured during memory allocation. */
30 INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
31 DRIVER_ERROR, /*!< A system driver error occured. */
32 SYSTEM_ERROR, /*!< A system error occured. */
33 THREAD_ERROR /*!< A thread error occured. */
42 RtError(const std::string& message, Type type = RtError::UNSPECIFIED) : message_(message), type_(type){}
45 virtual ~RtError(void) {};
47 //! Prints thrown error message to stderr.
48 virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; }
50 //! Returns the thrown error message type.
51 virtual const Type& getType(void) { return type_; }
53 //! Returns the thrown error message string.
54 virtual const std::string& getMessage(void) { return message_; }
56 //! Returns the thrown error message as a C string.
57 virtual const char *getMessageString(void) { return message_.c_str(); }