error.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. //
  2. // Copyright (c) 2019 Vinnie Falco ([email protected])
  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. /// A number is too large
  49. number_too_large,
  50. /// error occured when trying to read input
  51. input_error,
  52. //
  53. // generic errors
  54. //
  55. /// An exception was thrown during operation
  56. exception,
  57. /// A requested element is outside of container's range
  58. out_of_range,
  59. /// test failure
  60. test_failure,
  61. //
  62. // JSON Pointer errors
  63. //
  64. /// missing slash character before token reference
  65. missing_slash,
  66. /// invalid escape sequence
  67. invalid_escape,
  68. /// token should be a number but cannot be parsed as such
  69. token_not_number,
  70. /// current value is neither an object nor an array
  71. value_is_scalar,
  72. /// current value does not contain referenced value
  73. not_found,
  74. /// token cannot be represented by std::size_t
  75. token_overflow,
  76. /// past-the-end index is not supported
  77. past_the_end,
  78. //
  79. // Conversion errors
  80. //
  81. /// JSON number was expected during conversion
  82. not_number,
  83. /// number cast is not exact
  84. not_exact,
  85. /// JSON null was expected during conversion
  86. not_null,
  87. /// JSON bool was expected during conversion
  88. not_bool,
  89. /// JSON array was expected during conversion
  90. not_array,
  91. /// JSON object was expected during conversion
  92. not_object,
  93. /// JSON string was expected during conversion
  94. not_string,
  95. /// std::int64_t was expected during conversion
  96. not_int64,
  97. /// std::uint64_t was expected during conversion
  98. not_uint64,
  99. /// `double` was expected during conversion
  100. not_double,
  101. /// JSON integer was expected during conversion
  102. not_integer,
  103. /// source composite has size incompatible with target
  104. size_mismatch,
  105. /// none of the possible conversions were successful
  106. exhausted_variants,
  107. /// the key does not correspond to a known name
  108. unknown_name,
  109. };
  110. /** Error conditions corresponding to JSON errors
  111. */
  112. enum class condition
  113. {
  114. /// A parser-related error
  115. parse_error = 1,
  116. /// An error related to parsing JSON pointer string
  117. pointer_parse_error,
  118. /// An error related to applying JSON pointer string to a value
  119. pointer_use_error,
  120. /// A conversion error
  121. conversion_error,
  122. /// A generic error
  123. generic_error,
  124. };
  125. } // namespace json
  126. } // namespace boost
  127. #include <boost/json/impl/error.hpp>
  128. #endif