throw_error.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // detail/throw_error.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_DETAIL_THROW_ERROR_HPP
  11. #define BOOST_ASIO_DETAIL_THROW_ERROR_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <boost/asio/detail/throw_exception.hpp>
  17. #include <boost/system/error_code.hpp>
  18. #include <boost/asio/detail/push_options.hpp>
  19. namespace boost {
  20. namespace asio {
  21. namespace detail {
  22. BOOST_ASIO_DECL void do_throw_error(
  23. const boost::system::error_code& err
  24. BOOST_ASIO_SOURCE_LOCATION_PARAM);
  25. BOOST_ASIO_DECL void do_throw_error(
  26. const boost::system::error_code& err,
  27. const char* location
  28. BOOST_ASIO_SOURCE_LOCATION_PARAM);
  29. inline void throw_error(
  30. const boost::system::error_code& err
  31. BOOST_ASIO_SOURCE_LOCATION_DEFAULTED_PARAM)
  32. {
  33. if (err)
  34. do_throw_error(err BOOST_ASIO_SOURCE_LOCATION_ARG);
  35. }
  36. inline void throw_error(
  37. const boost::system::error_code& err,
  38. const char* location
  39. BOOST_ASIO_SOURCE_LOCATION_DEFAULTED_PARAM)
  40. {
  41. if (err)
  42. do_throw_error(err, location BOOST_ASIO_SOURCE_LOCATION_ARG);
  43. }
  44. } // namespace detail
  45. } // namespace asio
  46. } // namespace boost
  47. #include <boost/asio/detail/pop_options.hpp>
  48. #if defined(BOOST_ASIO_HEADER_ONLY)
  49. # include <boost/asio/detail/impl/throw_error.ipp>
  50. #endif // defined(BOOST_ASIO_HEADER_ONLY)
  51. #endif // BOOST_ASIO_DETAIL_THROW_ERROR_HPP