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 /************************************************************************/
19 class RtError
: public std::exception
22 //! Defined RtError types.
24 WARNING
, /*!< A non-critical error. */
25 DEBUG_WARNING
, /*!< A non-critical error which might be useful for debugging. */
26 UNSPECIFIED
, /*!< The default, unspecified error type. */
27 NO_DEVICES_FOUND
, /*!< No devices found on system. */
28 INVALID_DEVICE
, /*!< An invalid device ID was specified. */
29 MEMORY_ERROR
, /*!< An error occured during memory allocation. */
30 INVALID_PARAMETER
, /*!< An invalid parameter was specified to a function. */
31 INVALID_USE
, /*!< The function was called incorrectly. */
32 DRIVER_ERROR
, /*!< A system driver error occured. */
33 SYSTEM_ERROR
, /*!< A system error occured. */
34 THREAD_ERROR
/*!< A thread error occured. */
38 RtError( const std::string
& message
, Type type
= RtError::UNSPECIFIED
) throw() : message_(message
), type_(type
) {}
41 virtual ~RtError( void ) throw() {}
43 //! Prints thrown error message to stderr.
44 virtual void printMessage( void ) const throw() { std::cerr
<< '\n' << message_
<< "\n\n"; }
46 //! Returns the thrown error message type.
47 virtual const Type
& getType(void) const throw() { return type_
; }
49 //! Returns the thrown error message string.
50 virtual const std::string
& getMessage(void) const throw() { return message_
; }
52 //! Returns the thrown error message as a c-style string.
53 virtual const char* what( void ) const throw() { return message_
.c_str(); }