exception.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Boost.Geometry Index
  2. //
  3. // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
  4. //
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_GEOMETRY_INDEX_DETAIL_EXCEPTION_HPP
  9. #define BOOST_GEOMETRY_INDEX_DETAIL_EXCEPTION_HPP
  10. #include <boost/core/no_exceptions_support.hpp>
  11. #ifndef BOOST_NO_EXCEPTIONS
  12. #include <stdexcept>
  13. #include <boost/throw_exception.hpp>
  14. #else
  15. #include <cstdlib>
  16. #include <boost/geometry/index/detail/assert.hpp>
  17. #endif
  18. namespace boost { namespace geometry { namespace index { namespace detail {
  19. #ifndef BOOST_NO_EXCEPTIONS
  20. inline void throw_runtime_error(const char * str)
  21. {
  22. BOOST_THROW_EXCEPTION(std::runtime_error(str));
  23. }
  24. inline void throw_logic_error(const char * str)
  25. {
  26. BOOST_THROW_EXCEPTION(std::logic_error(str));
  27. }
  28. inline void throw_invalid_argument(const char * str)
  29. {
  30. BOOST_THROW_EXCEPTION(std::invalid_argument(str));
  31. }
  32. inline void throw_length_error(const char * str)
  33. {
  34. BOOST_THROW_EXCEPTION(std::length_error(str));
  35. }
  36. inline void throw_out_of_range(const char * str)
  37. {
  38. BOOST_THROW_EXCEPTION(std::out_of_range(str));
  39. }
  40. #else
  41. inline void throw_runtime_error(const char * str)
  42. {
  43. BOOST_GEOMETRY_INDEX_ASSERT(!"runtime_error thrown", str);
  44. std::abort();
  45. }
  46. inline void throw_logic_error(const char * str)
  47. {
  48. BOOST_GEOMETRY_INDEX_ASSERT(!"logic_error thrown", str);
  49. std::abort();
  50. }
  51. inline void throw_invalid_argument(const char * str)
  52. {
  53. BOOST_GEOMETRY_INDEX_ASSERT(!"invalid_argument thrown", str);
  54. std::abort();
  55. }
  56. inline void throw_length_error(const char * str)
  57. {
  58. BOOST_GEOMETRY_INDEX_ASSERT(!"length_error thrown", str);
  59. std::abort();
  60. }
  61. inline void throw_out_of_range(const char * str)
  62. {
  63. BOOST_GEOMETRY_INDEX_ASSERT(!"out_of_range thrown", str);
  64. std::abort();
  65. }
  66. #endif
  67. }}}} // namespace boost::geometry::index::detail
  68. #endif // BOOST_GEOMETRY_INDEX_DETAIL_EXCEPTION_HPP