1
1

jsonException.hh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * jsonException.hh for jsonstroller
  3. *
  4. * Author: isundil <isundill@gmail.com>
  5. **/
  6. #pragma once
  7. #include <exception>
  8. #include "config.h"
  9. #include "linearHistory.hh"
  10. class EofException: public std::exception
  11. { };
  12. class JsonException: public std::exception
  13. {
  14. public:
  15. JsonException(const std::string &what, unsigned long long offset, LinearHistory &buf);
  16. std::string getHistory() const;
  17. const char *what() const noexcept;
  18. unsigned int currentLine() const;
  19. protected:
  20. const unsigned long long offset;
  21. const LinearHistory history;
  22. const std::string _what;
  23. };
  24. class JsonHexvalueException: public JsonException
  25. {
  26. public:
  27. JsonHexvalueException(const std::string &what, unsigned long long offset, LinearHistory &hist);
  28. JsonHexvalueException(const char what, unsigned long long offset, LinearHistory &hist);
  29. static std::string msg(char c);
  30. };
  31. class JsonNotJsonException: public JsonException
  32. {
  33. public:
  34. JsonNotJsonException(unsigned long long offet, LinearHistory &h);
  35. };
  36. class JsonUnexpectedException: public JsonException
  37. {
  38. public:
  39. JsonUnexpectedException(const char expected, unsigned long long offset, LinearHistory &h);
  40. };
  41. class JsonFormatException: public JsonException
  42. {
  43. public:
  44. JsonFormatException(unsigned long long offset, LinearHistory &h);
  45. };
  46. class JsonEscapedException: public JsonException
  47. {
  48. public:
  49. JsonEscapedException(char c, unsigned long long offset, LinearHistory &h);
  50. protected:
  51. const char c;
  52. };