#ifndef VARIOUS_EXCEPTIONS_H #define VARIOUS_EXCEPTIONS_H #include #include using std::string; /** * Generic Exception class */ class RuntimeException { private: string errorMsg; public: RuntimeException(const string& err) { errorMsg = err; } string getMessage() const { return errorMsg; } }; inline std::ostream& operator<<(std::ostream& out, const RuntimeException& e) { return out << e.getMessage(); } /** * Exception thrown when trying to move past an end of a List */ class BoundaryViolationException : public RuntimeException { public: BoundaryViolationException(const string& err) : RuntimeException(err) {} }; /** * Exception thrown when asking for Position of empty list */ class EmptyContainerException : public RuntimeException { public: EmptyContainerException(const string& err) : RuntimeException(err) {} }; /** * Exception thrown when asking for card from empty hand. */ class EmptyHandException : public RuntimeException { public: EmptyHandException(const string& err) : RuntimeException(err) {} }; /** * Exception thrown when sending an invalid position as a parameter to a List method */ class InvalidPositionException : public RuntimeException { public: InvalidPositionException(const string& err) : RuntimeException(err) {} }; #endif