error.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/json
  8. //
  9. #ifndef BOOST_JSON_ERROR_HPP
  10. #define BOOST_JSON_ERROR_HPP
  11. #include <boost/json/detail/config.hpp>
  12. #include <boost/json/system_error.hpp>
  13. namespace boost {
  14. namespace json {
  15. /** Error codes returned by JSON operations
  16. */
  17. enum class error
  18. {
  19. //
  20. // parse errors
  21. //
  22. /// syntax error
  23. syntax = 1,
  24. /// extra data
  25. extra_data,
  26. /// incomplete JSON
  27. incomplete,
  28. /// exponent too large
  29. exponent_overflow,
  30. /// too deep
  31. too_deep,
  32. /// illegal leading surrogate
  33. illegal_leading_surrogate,
  34. /// illegal trailing surrogate
  35. illegal_trailing_surrogate,
  36. /// expected hex digit
  37. expected_hex_digit,
  38. /// expected utf16 escape
  39. expected_utf16_escape,
  40. /// An object contains too many elements
  41. object_too_large,
  42. /// An array contains too many elements
  43. array_too_large,
  44. /// A key is too large
  45. key_too_large,
  46. /// A string is too large
  47. string_too_large,
  48. /// error occured when trying to read input
  49. input_error,
  50. //
  51. // generic errors
  52. //
  53. /// An exception was thrown during operation
  54. exception,
  55. /// test failure
  56. test_failure,
  57. //
  58. // JSON Pointer errors
  59. //
  60. /// missing slash character before token reference
  61. missing_slash,
  62. /// invalid escape sequence
  63. invalid_escape,
  64. /// token should be a number but cannot be parsed as such
  65. token_not_number,
  66. /// current value is neither an object nor an array
  67. value_is_scalar,
  68. /// current value does not contain referenced value
  69. not_found,
  70. /// token cannot be represented by std::size_t
  71. token_overflow,
  72. /// past-the-end index is not supported
  73. past_the_end,
  74. //
  75. // Conversion errors
  76. //
  77. /// JSON number was expected during conversion
  78. not_number,
  79. /// number cast is not exact
  80. not_exact,
  81. /// JSON null was expected during conversion
  82. not_null,
  83. /// JSON bool was expected during conversion
  84. not_bool,
  85. /// JSON array was expected during conversion
  86. not_array,
  87. /// JSON object was expected during conversion
  88. not_object,
  89. /// JSON string was expected during conversion
  90. not_string,
  91. /// JSON array has size incompatible with target
  92. size_mismatch,
  93. /// none of the possible conversions were successful
  94. exhausted_variants,
  95. /// the key does not correspond to a known name
  96. unknown_name,
  97. };
  98. /** Error conditions corresponding to JSON errors
  99. */
  100. enum class condition
  101. {
  102. /// A parser-related error
  103. parse_error = 1,
  104. /// An error related to parsing JSON pointer string
  105. pointer_parse_error,
  106. /// An error related to applying JSON pointer string to a value
  107. pointer_use_error,
  108. /// A conversion error
  109. conversion_error,
  110. /// A generic error
  111. generic_error,
  112. };
  113. } // namespace json
  114. } // namespace boost
  115. #include <boost/json/impl/error.hpp>
  116. #endif