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