jsonException.hh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include <exception>
  3. #include "wrappedBuffer.hpp"
  4. class EofException: public std::exception
  5. { };
  6. class JsonException: public std::exception
  7. {
  8. public:
  9. JsonException(const std::string &what, unsigned long long offset, WrappedBuffer<char> &buf);
  10. std::string getHistory() const;
  11. const char *what() const noexcept;
  12. protected:
  13. const unsigned long long offset;
  14. const WrappedBuffer<char> history;
  15. const std::string _what;
  16. };
  17. class JsonNotJsonException: public JsonException
  18. {
  19. public:
  20. JsonNotJsonException(unsigned long long offet, WrappedBuffer<char> &h);
  21. };
  22. class JsonUnexpectedException: public JsonException
  23. {
  24. public:
  25. JsonUnexpectedException(const char expected, unsigned long long offset, WrappedBuffer<char> &h);
  26. };
  27. class JsonFormatException: public JsonException
  28. {
  29. public:
  30. JsonFormatException(unsigned long long offset, WrappedBuffer<char> &h);
  31. };
  32. class JsonEscapedException: public JsonException
  33. {
  34. public:
  35. JsonEscapedException(char c, unsigned long long offset, WrappedBuffer<char> &h);
  36. protected:
  37. const char c;
  38. };