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