throw_error.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // detail/throw_error.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2023 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 ASIO_DETAIL_THROW_ERROR_HPP
  11. #define 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 "asio/detail/config.hpp"
  16. #include "asio/detail/throw_exception.hpp"
  17. #include "asio/error_code.hpp"
  18. #include "asio/detail/push_options.hpp"
  19. namespace asio {
  20. namespace detail {
  21. ASIO_DECL void do_throw_error(
  22. const asio::error_code& err
  23. ASIO_SOURCE_LOCATION_PARAM);
  24. ASIO_DECL void do_throw_error(
  25. const asio::error_code& err,
  26. const char* location
  27. ASIO_SOURCE_LOCATION_PARAM);
  28. inline void throw_error(
  29. const asio::error_code& err
  30. ASIO_SOURCE_LOCATION_DEFAULTED_PARAM)
  31. {
  32. if (err)
  33. do_throw_error(err ASIO_SOURCE_LOCATION_ARG);
  34. }
  35. inline void throw_error(
  36. const asio::error_code& err,
  37. const char* location
  38. ASIO_SOURCE_LOCATION_DEFAULTED_PARAM)
  39. {
  40. if (err)
  41. do_throw_error(err, location ASIO_SOURCE_LOCATION_ARG);
  42. }
  43. } // namespace detail
  44. } // namespace asio
  45. #include "asio/detail/pop_options.hpp"
  46. #if defined(ASIO_HEADER_ONLY)
  47. # include "asio/detail/impl/throw_error.ipp"
  48. #endif // defined(ASIO_HEADER_ONLY)
  49. #endif // ASIO_DETAIL_THROW_ERROR_HPP