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 /************************************************************************/
20 //! Defined RtError types.
22 WARNING
, /*!< A non-critical error. */
23 DEBUG_WARNING
, /*!< A non-critical error which might be useful for debugging. */
24 UNSPECIFIED
, /*!< The default, unspecified error type. */
25 NO_DEVICES_FOUND
, /*!< No devices found on system. */
26 INVALID_DEVICE
, /*!< An invalid device ID was specified. */
27 INVALID_STREAM
, /*!< An invalid stream ID was specified. */
28 MEMORY_ERROR
, /*!< An error occured during memory allocation. */
29 INVALID_PARAMETER
, /*!< An invalid parameter was specified to a function. */
30 DRIVER_ERROR
, /*!< A system driver error occured. */
31 SYSTEM_ERROR
, /*!< A system error occured. */
32 THREAD_ERROR
/*!< A thread error occured. */
43 RtError(const std::string
& message
, Type type
= RtError::UNSPECIFIED
, long c
= 0 )
44 : message_(message
), type_(type
), continue_(c
) {}
47 virtual ~RtError(void) {};
49 //! Prints thrown error message to stderr.
50 virtual void printMessage(void) { fprintf( stderr
, "\n%s\n\n", message_
.c_str() ); }
52 //! Returns the thrown error message type.
53 virtual const Type
& getType(void) { return type_
; }
55 //! Returns the thrown error message string.
56 virtual const std::string
& getMessage(void) { return message_
; }
58 //! Returns the thrown error message as a C string.
59 virtual const char *getMessageString(void) { return message_
.c_str(); }
62 virtual const long getContinue() { return continue_
; }