jsonException.hh 1.3 KB

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