jsonException.hh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include <exception>
  3. #include "config.h"
  4. #include "linearHistory.hh"
  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, LinearHistory &buf);
  11. std::string getHistory() const;
  12. const char *what() const noexcept;
  13. unsigned int currentLine() const;
  14. protected:
  15. const unsigned long long offset;
  16. const LinearHistory history;
  17. const std::string _what;
  18. };
  19. class JsonHexvalueException: public JsonException
  20. {
  21. public:
  22. JsonHexvalueException(const std::string &what, unsigned long long offset, LinearHistory &hist);
  23. JsonHexvalueException(const char what, unsigned long long offset, LinearHistory &hist);
  24. static std::string msg(char c);
  25. };
  26. class JsonNotJsonException: public JsonException
  27. {
  28. public:
  29. JsonNotJsonException(unsigned long long offet, LinearHistory &h);
  30. };
  31. class JsonUnexpectedException: public JsonException
  32. {
  33. public:
  34. JsonUnexpectedException(const char expected, unsigned long long offset, LinearHistory &h);
  35. };
  36. class JsonFormatException: public JsonException
  37. {
  38. public:
  39. JsonFormatException(unsigned long long offset, LinearHistory &h);
  40. };
  41. class JsonEscapedException: public JsonException
  42. {
  43. public:
  44. JsonEscapedException(char c, unsigned long long offset, LinearHistory &h);
  45. protected:
  46. const char c;
  47. };