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
11#ifndef BOOST_ASIO_DETAIL_THROW_ERROR_HPP
12#define BOOST_ASIO_DETAIL_THROW_ERROR_HPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18#include <boost/asio/detail/config.hpp>
19#include <boost/asio/detail/throw_exception.hpp>
20#include <boost/system/error_code.hpp>
21
22#include <boost/asio/detail/push_options.hpp>
23
24namespace boost {
25namespace asio {
26namespace detail {
27
28BOOST_ASIO_DECL void do_throw_error(
29 const boost::system::error_code& err
30 BOOST_ASIO_SOURCE_LOCATION_PARAM);
31
32BOOST_ASIO_DECL void do_throw_error(
33 const boost::system::error_code& err,
34 const char* location
35 BOOST_ASIO_SOURCE_LOCATION_PARAM);
36
37inline void throw_error(
38 const boost::system::error_code& err
39 BOOST_ASIO_SOURCE_LOCATION_DEFAULTED_PARAM)
40{
41 if (err)
42 do_throw_error(err BOOST_ASIO_SOURCE_LOCATION_ARG);
43}
44
45inline void throw_error(
46 const boost::system::error_code& err,
47 const char* location
48 BOOST_ASIO_SOURCE_LOCATION_DEFAULTED_PARAM)
49{
50 if (err)
51 do_throw_error(err, location BOOST_ASIO_SOURCE_LOCATION_ARG);
52}
53
54} // namespace detail
55} // namespace asio
56} // namespace boost
57
58#include <boost/asio/detail/pop_options.hpp>
59
60#if defined(BOOST_ASIO_HEADER_ONLY)
61# include <boost/asio/detail/impl/throw_error.ipp>
62#endif // defined(BOOST_ASIO_HEADER_ONLY)
63
64#endif // BOOST_ASIO_DETAIL_THROW_ERROR_HPP
65

source code of boost/libs/asio/include/boost/asio/detail/throw_error.hpp