/** A class for complex numbers. C.A. Bertulani 06/12/2000 */ #ifndef _EXCEPTIONS_H_ #define _EXCEPTIONS_H_ #include class Exception { // prints the exception message to the output stream friend ostream& operator<<( ostream& outStream, const Exception& exception) { outStream << exception.exceptionType_ << ": " << exception.message_; return outStream; } public: // creates a general exception with the given message Exception( const char* message) : message_(message), exceptionType_( "General Exception"){} protected: // used by subclasses to "personize" themselves. Exception( const char* message, const char* type) : message_(message), exceptionType_( type){} const char* exceptionType_; const char* message_; }; class OutOfRangeException : public Exception { public: OutOfRangeException( const char* message) : Exception( message, "Value Out of Range") {} }; class IO_Exception : public Exception { public: IO_Exception( const char* message) : Exception( message, "IO Failure") {} }; class UnexpectedNullException : public Exception { public: UnexpectedNullException( const char* message) : Exception( message, "Unexpected Null Value") {} }; #endif // ends exceptions.h