• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// impl/error.ipp
3// ~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2021 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_IMPL_ERROR_IPP
12#define BOOST_ASIO_IMPL_ERROR_IPP
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 <string>
20#include <boost/asio/error.hpp>
21
22#include <boost/asio/detail/push_options.hpp>
23
24namespace boost {
25namespace asio {
26namespace error {
27
28#if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
29
30namespace detail {
31
32class netdb_category : public boost::system::error_category
33{
34public:
35  const char* name() const BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT
36  {
37    return "asio.netdb";
38  }
39
40  std::string message(int value) const
41  {
42    if (value == error::host_not_found)
43      return "Host not found (authoritative)";
44    if (value == error::host_not_found_try_again)
45      return "Host not found (non-authoritative), try again later";
46    if (value == error::no_data)
47      return "The query is valid, but it does not have associated data";
48    if (value == error::no_recovery)
49      return "A non-recoverable error occurred during database lookup";
50    return "asio.netdb error";
51  }
52};
53
54} // namespace detail
55
56const boost::system::error_category& get_netdb_category()
57{
58  static detail::netdb_category instance;
59  return instance;
60}
61
62namespace detail {
63
64class addrinfo_category : public boost::system::error_category
65{
66public:
67  const char* name() const BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT
68  {
69    return "asio.addrinfo";
70  }
71
72  std::string message(int value) const
73  {
74    if (value == error::service_not_found)
75      return "Service not found";
76    if (value == error::socket_type_not_supported)
77      return "Socket type not supported";
78    return "asio.addrinfo error";
79  }
80};
81
82} // namespace detail
83
84const boost::system::error_category& get_addrinfo_category()
85{
86  static detail::addrinfo_category instance;
87  return instance;
88}
89
90#endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
91
92namespace detail {
93
94class misc_category : public boost::system::error_category
95{
96public:
97  const char* name() const BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT
98  {
99    return "asio.misc";
100  }
101
102  std::string message(int value) const
103  {
104    if (value == error::already_open)
105      return "Already open";
106    if (value == error::eof)
107      return "End of file";
108    if (value == error::not_found)
109      return "Element not found";
110    if (value == error::fd_set_failure)
111      return "The descriptor does not fit into the select call's fd_set";
112    return "asio.misc error";
113  }
114};
115
116} // namespace detail
117
118const boost::system::error_category& get_misc_category()
119{
120  static detail::misc_category instance;
121  return instance;
122}
123
124} // namespace error
125} // namespace asio
126} // namespace boost
127
128#include <boost/asio/detail/pop_options.hpp>
129
130#endif // BOOST_ASIO_IMPL_ERROR_IPP
131