summaryrefslogtreecommitdiff
path: root/RtError.h
diff options
context:
space:
mode:
authorGary Scavone <gary@music.mcgill.ca>2013-10-11 14:49:11 +0200
committerStephen Sinclair <sinclair@music.mcgill.ca>2013-10-11 14:49:11 +0200
commit330e5ca540bee67d0648def2d303e9e1d366cb53 (patch)
treede4c10fcd95454e401b944d84a6fe6250a2f959f /RtError.h
parent8fec3d71d441efbada609d2139ddf8ff6aa7b914 (diff)
Version 1.0.13
Diffstat (limited to 'RtError.h')
-rw-r--r--RtError.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/RtError.h b/RtError.h
index cb1283d..a64f434 100644
--- a/RtError.h
+++ b/RtError.h
@@ -12,12 +12,13 @@
#ifndef RTERROR_H
#define RTERROR_H
+#include <exception>
#include <iostream>
#include <string>
-class RtError
+class RtError : public std::exception
{
-public:
+ public:
//! Defined RtError types.
enum Type {
WARNING, /*!< A non-critical error. */
@@ -25,36 +26,35 @@ public:
UNSPECIFIED, /*!< The default, unspecified error type. */
NO_DEVICES_FOUND, /*!< No devices found on system. */
INVALID_DEVICE, /*!< An invalid device ID was specified. */
- INVALID_STREAM, /*!< An invalid stream ID was specified. */
MEMORY_ERROR, /*!< An error occured during memory allocation. */
INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
+ INVALID_USE, /*!< The function was called incorrectly. */
DRIVER_ERROR, /*!< A system driver error occured. */
SYSTEM_ERROR, /*!< A system error occured. */
THREAD_ERROR /*!< A thread error occured. */
};
-protected:
- std::string message_;
- Type type_;
-
-public:
//! The constructor.
- RtError(const std::string& message, Type type = RtError::UNSPECIFIED) : message_(message), type_(type) {}
-
+ RtError( const std::string& message, Type type = RtError::UNSPECIFIED ) throw() : message_(message), type_(type) {}
+
//! The destructor.
- virtual ~RtError(void) {};
+ virtual ~RtError( void ) throw() {}
//! Prints thrown error message to stderr.
- virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; }
+ virtual void printMessage( void ) const throw() { std::cerr << '\n' << message_ << "\n\n"; }
//! Returns the thrown error message type.
- virtual const Type& getType(void) { return type_; }
+ virtual const Type& getType(void) const throw() { return type_; }
//! Returns the thrown error message string.
- virtual const std::string& getMessage(void) { return message_; }
+ virtual const std::string& getMessage(void) const throw() { return message_; }
- //! Returns the thrown error message as a C string.
- virtual const char *getMessageString(void) { return message_.c_str(); }
+ //! Returns the thrown error message as a c-style string.
+ virtual const char* what( void ) const throw() { return message_.c_str(); }
+
+ protected:
+ std::string message_;
+ Type type_;
};
#endif