class ldraw_error : public std::exception { public: enum error_type { warning, user_error, fatal, fixme }; explicit ldraw_error(const std::string &location, error_type type, const std::string &details) : m_location(location), m_type(type), m_details(details) {} virtual ~ldraw_error() throw() {} virtual const char* what() const throw() { std::string s; switch(m_type) { case warning: s = "warning"; break; case user_error: s = "user_error"; break; case fatal: s = "error"; break; case fixme: s = "fixme"; break; default: s = ""; } return (std::string("[libLDR] ") + s + " in " + m_location + ": " + m_details).c_str(); } const std::string location() const { return m_location; } error_type type() const { return m_type; } const std::string details() const { return m_details; } protected: std::string m_location; error_type m_type; std::string m_details; };