*** empty log message ***
[chuck-blob.git] / v2 / rterror.h
blobbb8b3d471d8bd80c28229b4fd8d95b08e8b86369
1 /************************************************************************/
2 /*! \class RtError
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.
9 */
10 /************************************************************************/
11 #ifndef RTERROR_H
12 #define RTERROR_H
14 #include <stdio.h>
15 #include <string>
17 class RtError
19 public:
20 //! Defined RtError types.
21 enum Type {
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. */
35 protected:
36 std::string message_;
37 Type type_;
39 public:
40 long continue_;
42 //! The constructor.
43 RtError(const std::string& message, Type type = RtError::UNSPECIFIED, long c = 0 )
44 : message_(message), type_(type), continue_(c) {}
46 //! The destructor.
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(); }
61 // don't stop
62 virtual const long getContinue() { return continue_; }
65 #endif