except.ipp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_DETAIL_IMPL_EXCEPT_IPP
  10. #define BOOST_JSON_DETAIL_IMPL_EXCEPT_IPP
  11. #include <boost/json/detail/except.hpp>
  12. #include <boost/version.hpp>
  13. #include <boost/throw_exception.hpp>
  14. #include <stdexcept>
  15. namespace boost {
  16. namespace json {
  17. namespace detail {
  18. void
  19. throw_bad_alloc(
  20. source_location const& loc)
  21. {
  22. throw_exception(
  23. std::bad_alloc(),
  24. loc);
  25. }
  26. void
  27. throw_length_error(
  28. char const* what,
  29. source_location const& loc)
  30. {
  31. throw_exception(
  32. std::length_error(what),
  33. loc);
  34. }
  35. void
  36. throw_invalid_argument(
  37. char const* what,
  38. source_location const& loc)
  39. {
  40. throw_exception(
  41. std::invalid_argument(what),
  42. loc);
  43. }
  44. void
  45. throw_out_of_range(
  46. source_location const& loc)
  47. {
  48. throw_exception(
  49. std::out_of_range(
  50. "out of range"),
  51. loc);
  52. }
  53. void
  54. throw_system_error(
  55. error_code const& ec,
  56. source_location const& loc)
  57. {
  58. throw_exception(
  59. system_error(ec),
  60. loc);
  61. }
  62. } // detail
  63. } // namespace json
  64. } // namespace boost
  65. #endif