Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyException : public std::exception(?)
- {
- public:
- enum Status
- {
- ERROR_FOO,
- ERROR_BAR,
- ...
- };
- MyException(const std::string& error, Status code) :
- error_(error), code_(code)
- {
- ...
- }
- virtual const char* what() const
- {
- return error_.c_str();
- }
- Status code() const
- {
- return code_;
- }
- private:
- std::string error_;
- Status code_;
- };
- throw MyException("Ooops!", MyException::ERROR_BAR);
- class MyException : public std::exception
- {
- public:
- enum Status
- {
- ERROR_FOO,
- ERROR_BAR,
- ...
- };
- MyException(const char* error, Status code) :
- std::exception(error),
- code_(code)
- {
- ...
- }
- ...
- private:
- Status code_;
- };
- // What is a no throw operation.
- virtual const char* what() const throw ()
- {
- return error_.c_str();
- }
- class MyException: public std::runtime_error
- { // STUFF .. Put all the error message stuff here
- };
- class MyFOO_Exception: public MyException
- { // STUFF
- };
- class MyBAR_Exception: public MyException
- { // STUFF
- }
Add Comment
Please, Sign In to add comment