exceptions.h 970 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * exceptions.h
  3. *
  4. * Created on: Mar 20, 2017
  5. * Author: hp
  6. */
  7. #ifndef LIB_MACAROON_EXCEPTIONS_H_
  8. #define LIB_MACAROON_EXCEPTIONS_H_
  9. #include <stdexcept>
  10. namespace macaroons {
  11. class exception: public std::exception {
  12. public:
  13. exception() {
  14. }
  15. explicit exception(const char* message) :
  16. msg_(message) {
  17. }
  18. explicit exception(const std::string& message) :
  19. msg_(message) {
  20. }
  21. virtual ~exception() throw () {
  22. }
  23. virtual const char* what() const throw () {
  24. return msg_.c_str();
  25. }
  26. protected:
  27. std::string msg_;
  28. };
  29. class authentication_exception: public exception {
  30. public:
  31. explicit authentication_exception(const char* message) :
  32. msg_(message) {
  33. }
  34. explicit authentication_exception(const std::string& message) :
  35. msg_(message) {
  36. }
  37. virtual ~authentication_exception() throw () {
  38. }
  39. virtual const char* what() const throw () {
  40. return msg_.c_str();
  41. }
  42. protected:
  43. std::string msg_;
  44. };
  45. }
  46. #endif /* LIB_MACAROON_EXCEPTIONS_H_ */