Logo Search packages:      
Sourcecode: csound version File versions  Download package

RtError.h

/************************************************************************/
/*! \class RtError
    \brief Exception handling class for RtAudio & RtMidi.

    The RtError class is quite simple but it does allow errors to be
    "caught" by RtError::Type. See the RtAudio and RtMidi
    documentation to know which methods can throw an RtError.

*/
/************************************************************************/

#ifndef RTERROR_H
#define RTERROR_H

#include <iostream>
#include <string>

00018 class RtError
{
public:
  //! Defined RtError types.
00022   enum Type {
00023     WARNING,           /*!< A non-critical error. */
00024     DEBUG_WARNING,     /*!< A non-critical error which might be useful for debugging. */
00025     UNSPECIFIED,       /*!< The default, unspecified error type. */
00026     NO_DEVICES_FOUND,  /*!< No devices found on system. */
00027     INVALID_DEVICE,    /*!< An invalid device ID was specified. */
00028     INVALID_STREAM,    /*!< An invalid stream ID was specified. */
00029     MEMORY_ERROR,      /*!< An error occured during memory allocation. */
00030     INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
00031     DRIVER_ERROR,      /*!< A system driver error occured. */
00032     SYSTEM_ERROR,      /*!< A system error occured. */
00033     THREAD_ERROR       /*!< A thread error occured. */
  };

protected:
  std::string message_;
  Type type_;

public:
  //! The constructor.
00042   RtError(const std::string& message, Type type = RtError::UNSPECIFIED) : message_(message), type_(type) {}

  //! The destructor.
00045   virtual ~RtError(void) {};

  //! Prints thrown error message to stderr.
00048   virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; }

  //! Returns the thrown error message type.
00051   virtual const Type& getType(void) { return type_; }

  //! Returns the thrown error message string.
00054   virtual const std::string& getMessage(void) { return message_; }

  //! Returns the thrown error message as a C string.
00057   virtual const char *getMessageString(void) { return message_.c_str(); }
};

#endif

Generated by  Doxygen 1.6.0   Back to index