I've been pondering which of these 2 approaches would make for the best interface for a library: Defining custom exceptions with specific names for different error scenarios but with standard behaviour, or simply using the predefined exceptions from the STL.
This is my current approach:
This seems to make for more descriptive code but it adds no functionality and the implementations are completely identical, which seems "off" to me, somehow.Code:namespace rpp { class ConnectionError : public std::exception { public: ConnectionError(const std::string &p_err); const char* what() const throw(); private: std::string m_err; }; class AuthenticationError : public std::exception { public: AuthenticationError(const std::string &p_err); const char* what() const throw(); private: std::string m_err; }; class ParsingError : public std::exception { public: ParsingError(const std::string &p_err); const char* what() const throw(); private: std::string m_err; }; class Error : public std::exception { public: Error(const std::string &p_err); const char* what() const throw(); private: std::string m_err; }; }