error.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. namespace boost {
  13. namespace json {
  14. /// Error codes returned by JSON operations
  15. enum class error
  16. {
  17. //
  18. // parse errors
  19. //
  20. /// syntax error
  21. syntax = 1,
  22. /// extra data
  23. extra_data,
  24. /// incomplete JSON
  25. incomplete,
  26. /// exponent too large
  27. exponent_overflow,
  28. /// too deep
  29. too_deep,
  30. /// illegal leading surrogate
  31. illegal_leading_surrogate,
  32. /// illegal trailing surrogate
  33. illegal_trailing_surrogate,
  34. /// expected hex digit
  35. expected_hex_digit,
  36. /// expected utf16 escape
  37. expected_utf16_escape,
  38. /// An object contains too many elements
  39. object_too_large,
  40. /// An array contains too many elements
  41. array_too_large,
  42. /// A key is too large
  43. key_too_large,
  44. /// A string is too large
  45. string_too_large,
  46. /// A number is too large
  47. number_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. /// A requested element is outside of container's range
  56. out_of_range,
  57. /// test failure
  58. test_failure,
  59. //
  60. // JSON Pointer errors
  61. //
  62. /// missing slash character before token reference
  63. missing_slash,
  64. /// invalid escape sequence
  65. invalid_escape,
  66. /// token should be a number but cannot be parsed as such
  67. token_not_number,
  68. /// current value is neither an object nor an array
  69. value_is_scalar,
  70. /// current value does not contain referenced value
  71. not_found,
  72. /// token cannot be represented by std::size_t
  73. token_overflow,
  74. /// past-the-end index is not supported
  75. past_the_end,
  76. //
  77. // Conversion errors
  78. //
  79. /// JSON number was expected during conversion
  80. not_number,
  81. /// number cast is not exact
  82. not_exact,
  83. /// JSON null was expected during conversion
  84. not_null,
  85. /// JSON bool was expected during conversion
  86. not_bool,
  87. /// JSON array was expected during conversion
  88. not_array,
  89. /// JSON object was expected during conversion
  90. not_object,
  91. /// JSON string was expected during conversion
  92. not_string,
  93. /// std::int64_t was expected during conversion
  94. not_int64,
  95. /// std::uint64_t was expected during conversion
  96. not_uint64,
  97. /// `double` was expected during conversion
  98. not_double,
  99. /// JSON integer was expected during conversion
  100. not_integer,
  101. /// source composite has size incompatible with target
  102. size_mismatch,
  103. /// none of the possible conversions were successful
  104. exhausted_variants,
  105. /// the key does not correspond to a known name
  106. unknown_name,
  107. };
  108. /// Error conditions corresponding to JSON errors
  109. enum class condition
  110. {
  111. /// A parser-related error
  112. parse_error = 1,
  113. /// An error related to parsing JSON pointer string
  114. pointer_parse_error,
  115. /// An error related to applying JSON pointer string to a value
  116. pointer_use_error,
  117. /// A conversion error
  118. conversion_error,
  119. /// A generic error
  120. generic_error,
  121. };
  122. } // namespace json
  123. } // namespace boost
  124. #include <boost/json/impl/error.hpp>
  125. #endif