Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:43:39

0001 //
0002 // error.hpp
0003 // ~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_ERROR_HPP
0012 #define BOOST_ASIO_ERROR_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/cerrno.hpp>
0020 #include <boost/system/error_code.hpp>
0021 #include <boost/system/system_error.hpp>
0022 #if defined(BOOST_ASIO_WINDOWS) \
0023   || defined(__CYGWIN__) \
0024   || defined(BOOST_ASIO_WINDOWS_RUNTIME)
0025 # include <winerror.h>
0026 #else
0027 # include <cerrno>
0028 # include <netdb.h>
0029 #endif
0030 
0031 #if defined(GENERATING_DOCUMENTATION)
0032 /// INTERNAL ONLY.
0033 # define BOOST_ASIO_NATIVE_ERROR(e) implementation_defined
0034 /// INTERNAL ONLY.
0035 # define BOOST_ASIO_SOCKET_ERROR(e) implementation_defined
0036 /// INTERNAL ONLY.
0037 # define BOOST_ASIO_NETDB_ERROR(e) implementation_defined
0038 /// INTERNAL ONLY.
0039 # define BOOST_ASIO_GETADDRINFO_ERROR(e) implementation_defined
0040 /// INTERNAL ONLY.
0041 # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) implementation_defined
0042 #elif defined(BOOST_ASIO_WINDOWS_RUNTIME)
0043 # define BOOST_ASIO_NATIVE_ERROR(e) __HRESULT_FROM_WIN32(e)
0044 # define BOOST_ASIO_SOCKET_ERROR(e) __HRESULT_FROM_WIN32(WSA ## e)
0045 # define BOOST_ASIO_NETDB_ERROR(e) __HRESULT_FROM_WIN32(WSA ## e)
0046 # define BOOST_ASIO_GETADDRINFO_ERROR(e) __HRESULT_FROM_WIN32(WSA ## e)
0047 # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_win
0048 #elif defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
0049 # define BOOST_ASIO_NATIVE_ERROR(e) e
0050 # define BOOST_ASIO_SOCKET_ERROR(e) WSA ## e
0051 # define BOOST_ASIO_NETDB_ERROR(e) WSA ## e
0052 # define BOOST_ASIO_GETADDRINFO_ERROR(e) WSA ## e
0053 # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_win
0054 #else
0055 # define BOOST_ASIO_NATIVE_ERROR(e) e
0056 # define BOOST_ASIO_SOCKET_ERROR(e) e
0057 # define BOOST_ASIO_NETDB_ERROR(e) e
0058 # define BOOST_ASIO_GETADDRINFO_ERROR(e) e
0059 # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_posix
0060 #endif
0061 
0062 #include <boost/asio/detail/push_options.hpp>
0063 
0064 namespace boost {
0065 namespace asio {
0066 namespace error {
0067 
0068 enum basic_errors
0069 {
0070   /// Permission denied.
0071   access_denied = BOOST_ASIO_SOCKET_ERROR(EACCES),
0072 
0073   /// Address family not supported by protocol.
0074   address_family_not_supported = BOOST_ASIO_SOCKET_ERROR(EAFNOSUPPORT),
0075 
0076   /// Address already in use.
0077   address_in_use = BOOST_ASIO_SOCKET_ERROR(EADDRINUSE),
0078 
0079   /// Transport endpoint is already connected.
0080   already_connected = BOOST_ASIO_SOCKET_ERROR(EISCONN),
0081 
0082   /// Operation already in progress.
0083   already_started = BOOST_ASIO_SOCKET_ERROR(EALREADY),
0084 
0085   /// Broken pipe.
0086   broken_pipe = BOOST_ASIO_WIN_OR_POSIX(
0087       BOOST_ASIO_NATIVE_ERROR(ERROR_BROKEN_PIPE),
0088       BOOST_ASIO_NATIVE_ERROR(EPIPE)),
0089 
0090   /// A connection has been aborted.
0091   connection_aborted = BOOST_ASIO_SOCKET_ERROR(ECONNABORTED),
0092 
0093   /// Connection refused.
0094   connection_refused = BOOST_ASIO_SOCKET_ERROR(ECONNREFUSED),
0095 
0096   /// Connection reset by peer.
0097   connection_reset = BOOST_ASIO_SOCKET_ERROR(ECONNRESET),
0098 
0099   /// Bad file descriptor.
0100   bad_descriptor = BOOST_ASIO_SOCKET_ERROR(EBADF),
0101 
0102   /// Bad address.
0103   fault = BOOST_ASIO_SOCKET_ERROR(EFAULT),
0104 
0105   /// No route to host.
0106   host_unreachable = BOOST_ASIO_SOCKET_ERROR(EHOSTUNREACH),
0107 
0108   /// Operation now in progress.
0109   in_progress = BOOST_ASIO_SOCKET_ERROR(EINPROGRESS),
0110 
0111   /// Interrupted system call.
0112   interrupted = BOOST_ASIO_SOCKET_ERROR(EINTR),
0113 
0114   /// Invalid argument.
0115   invalid_argument = BOOST_ASIO_SOCKET_ERROR(EINVAL),
0116 
0117   /// Message too long.
0118   message_size = BOOST_ASIO_SOCKET_ERROR(EMSGSIZE),
0119 
0120   /// The name was too long.
0121   name_too_long = BOOST_ASIO_SOCKET_ERROR(ENAMETOOLONG),
0122 
0123   /// Network is down.
0124   network_down = BOOST_ASIO_SOCKET_ERROR(ENETDOWN),
0125 
0126   /// Network dropped connection on reset.
0127   network_reset = BOOST_ASIO_SOCKET_ERROR(ENETRESET),
0128 
0129   /// Network is unreachable.
0130   network_unreachable = BOOST_ASIO_SOCKET_ERROR(ENETUNREACH),
0131 
0132   /// Too many open files.
0133   no_descriptors = BOOST_ASIO_SOCKET_ERROR(EMFILE),
0134 
0135   /// No buffer space available.
0136   no_buffer_space = BOOST_ASIO_SOCKET_ERROR(ENOBUFS),
0137 
0138   /// Cannot allocate memory.
0139   no_memory = BOOST_ASIO_WIN_OR_POSIX(
0140       BOOST_ASIO_NATIVE_ERROR(ERROR_OUTOFMEMORY),
0141       BOOST_ASIO_NATIVE_ERROR(ENOMEM)),
0142 
0143   /// Operation not permitted.
0144   no_permission = BOOST_ASIO_WIN_OR_POSIX(
0145       BOOST_ASIO_NATIVE_ERROR(ERROR_ACCESS_DENIED),
0146       BOOST_ASIO_NATIVE_ERROR(EPERM)),
0147 
0148   /// Protocol not available.
0149   no_protocol_option = BOOST_ASIO_SOCKET_ERROR(ENOPROTOOPT),
0150 
0151   /// No such device.
0152   no_such_device = BOOST_ASIO_WIN_OR_POSIX(
0153       BOOST_ASIO_NATIVE_ERROR(ERROR_BAD_UNIT),
0154       BOOST_ASIO_NATIVE_ERROR(ENODEV)),
0155 
0156   /// Transport endpoint is not connected.
0157   not_connected = BOOST_ASIO_SOCKET_ERROR(ENOTCONN),
0158 
0159   /// Socket operation on non-socket.
0160   not_socket = BOOST_ASIO_SOCKET_ERROR(ENOTSOCK),
0161 
0162   /// Operation cancelled.
0163   operation_aborted = BOOST_ASIO_WIN_OR_POSIX(
0164       BOOST_ASIO_NATIVE_ERROR(ERROR_OPERATION_ABORTED),
0165       BOOST_ASIO_NATIVE_ERROR(ECANCELED)),
0166 
0167   /// Operation not supported.
0168   operation_not_supported = BOOST_ASIO_SOCKET_ERROR(EOPNOTSUPP),
0169 
0170   /// Cannot send after transport endpoint shutdown.
0171   shut_down = BOOST_ASIO_SOCKET_ERROR(ESHUTDOWN),
0172 
0173   /// Connection timed out.
0174   timed_out = BOOST_ASIO_SOCKET_ERROR(ETIMEDOUT),
0175 
0176   /// Resource temporarily unavailable.
0177   try_again = BOOST_ASIO_WIN_OR_POSIX(
0178       BOOST_ASIO_NATIVE_ERROR(ERROR_RETRY),
0179       BOOST_ASIO_NATIVE_ERROR(EAGAIN)),
0180 
0181   /// The socket is marked non-blocking and the requested operation would block.
0182   would_block = BOOST_ASIO_SOCKET_ERROR(EWOULDBLOCK)
0183 };
0184 
0185 enum netdb_errors
0186 {
0187   /// Host not found (authoritative).
0188   host_not_found = BOOST_ASIO_NETDB_ERROR(HOST_NOT_FOUND),
0189 
0190   /// Host not found (non-authoritative).
0191   host_not_found_try_again = BOOST_ASIO_NETDB_ERROR(TRY_AGAIN),
0192 
0193   /// The query is valid but does not have associated address data.
0194   no_data = BOOST_ASIO_NETDB_ERROR(NO_DATA),
0195 
0196   /// A non-recoverable error occurred.
0197   no_recovery = BOOST_ASIO_NETDB_ERROR(NO_RECOVERY)
0198 };
0199 
0200 enum addrinfo_errors
0201 {
0202   /// The service is not supported for the given socket type.
0203   service_not_found = BOOST_ASIO_WIN_OR_POSIX(
0204       BOOST_ASIO_NATIVE_ERROR(WSATYPE_NOT_FOUND),
0205       BOOST_ASIO_GETADDRINFO_ERROR(EAI_SERVICE)),
0206 
0207   /// The socket type is not supported.
0208   socket_type_not_supported = BOOST_ASIO_WIN_OR_POSIX(
0209       BOOST_ASIO_NATIVE_ERROR(WSAESOCKTNOSUPPORT),
0210       BOOST_ASIO_GETADDRINFO_ERROR(EAI_SOCKTYPE))
0211 };
0212 
0213 enum misc_errors
0214 {
0215   /// Already open.
0216   already_open = 1,
0217 
0218   /// End of file or stream.
0219   eof,
0220 
0221   /// Element not found.
0222   not_found,
0223 
0224   /// The descriptor cannot fit into the select system call's fd_set.
0225   fd_set_failure
0226 };
0227 
0228 #if !defined(BOOST_ASIO_ERROR_LOCATION) \
0229   && !defined(BOOST_ASIO_DISABLE_ERROR_LOCATION) \
0230   && defined(BOOST_ASIO_HAS_BOOST_CONFIG) \
0231   && (BOOST_VERSION >= 107900)
0232 
0233 # define BOOST_ASIO_ERROR_LOCATION(e) \
0234   do { \
0235     BOOST_STATIC_CONSTEXPR boost::source_location loc \
0236       = BOOST_CURRENT_LOCATION; \
0237     (e).assign((e), &loc); \
0238   } while (false)
0239 
0240 #else // !defined(BOOST_ASIO_ERROR_LOCATION)
0241       //   && !defined(BOOST_ASIO_DISABLE_ERROR_LOCATION)
0242       //   && defined(BOOST_ASIO_HAS_BOOST_CONFIG)
0243       //   && (BOOST_VERSION >= 107900)
0244 
0245 # define BOOST_ASIO_ERROR_LOCATION(e) (void)0
0246 
0247 #endif // !defined(BOOST_ASIO_ERROR_LOCATION)
0248        //   && !defined(BOOST_ASIO_DISABLE_ERROR_LOCATION)
0249        //   && defined(BOOST_ASIO_HAS_BOOST_CONFIG)
0250        //   && (BOOST_VERSION >= 107900)
0251 
0252 inline void clear(boost::system::error_code& ec)
0253 {
0254   ec = boost::system::error_code();
0255 }
0256 
0257 inline const boost::system::error_category& get_system_category()
0258 {
0259   return boost::system::system_category();
0260 }
0261 
0262 #if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
0263 
0264 extern BOOST_ASIO_DECL
0265 const boost::system::error_category& get_netdb_category();
0266 
0267 extern BOOST_ASIO_DECL
0268 const boost::system::error_category& get_addrinfo_category();
0269 
0270 #else // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
0271 
0272 inline const boost::system::error_category& get_netdb_category()
0273 {
0274   return get_system_category();
0275 }
0276 
0277 inline const boost::system::error_category& get_addrinfo_category()
0278 {
0279   return get_system_category();
0280 }
0281 
0282 #endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
0283 
0284 extern BOOST_ASIO_DECL
0285 const boost::system::error_category& get_misc_category();
0286 
0287 static const boost::system::error_category&
0288   system_category BOOST_ASIO_UNUSED_VARIABLE
0289   = boost::asio::error::get_system_category();
0290 static const boost::system::error_category&
0291   netdb_category BOOST_ASIO_UNUSED_VARIABLE
0292   = boost::asio::error::get_netdb_category();
0293 static const boost::system::error_category&
0294   addrinfo_category BOOST_ASIO_UNUSED_VARIABLE
0295   = boost::asio::error::get_addrinfo_category();
0296 static const boost::system::error_category&
0297   misc_category BOOST_ASIO_UNUSED_VARIABLE
0298   = boost::asio::error::get_misc_category();
0299 
0300 } // namespace error
0301 } // namespace asio
0302 } // namespace boost
0303 
0304 namespace boost {
0305 namespace system {
0306 
0307 template<> struct is_error_code_enum<boost::asio::error::basic_errors>
0308 {
0309   static const bool value = true;
0310 };
0311 
0312 template<> struct is_error_code_enum<boost::asio::error::netdb_errors>
0313 {
0314   static const bool value = true;
0315 };
0316 
0317 template<> struct is_error_code_enum<boost::asio::error::addrinfo_errors>
0318 {
0319   static const bool value = true;
0320 };
0321 
0322 template<> struct is_error_code_enum<boost::asio::error::misc_errors>
0323 {
0324   static const bool value = true;
0325 };
0326 
0327 } // namespace system
0328 } // namespace boost
0329 
0330 namespace boost {
0331 namespace asio {
0332 namespace error {
0333 
0334 inline boost::system::error_code make_error_code(basic_errors e)
0335 {
0336   return boost::system::error_code(
0337       static_cast<int>(e), get_system_category());
0338 }
0339 
0340 inline boost::system::error_code make_error_code(netdb_errors e)
0341 {
0342   return boost::system::error_code(
0343       static_cast<int>(e), get_netdb_category());
0344 }
0345 
0346 inline boost::system::error_code make_error_code(addrinfo_errors e)
0347 {
0348   return boost::system::error_code(
0349       static_cast<int>(e), get_addrinfo_category());
0350 }
0351 
0352 inline boost::system::error_code make_error_code(misc_errors e)
0353 {
0354   return boost::system::error_code(
0355       static_cast<int>(e), get_misc_category());
0356 }
0357 
0358 } // namespace error
0359 namespace stream_errc {
0360   // Simulates the proposed stream_errc scoped enum.
0361   using error::eof;
0362   using error::not_found;
0363 } // namespace stream_errc
0364 namespace socket_errc {
0365   // Simulates the proposed socket_errc scoped enum.
0366   using error::already_open;
0367   using error::not_found;
0368 } // namespace socket_errc
0369 namespace resolver_errc {
0370   // Simulates the proposed resolver_errc scoped enum.
0371   using error::host_not_found;
0372   const error::netdb_errors try_again = error::host_not_found_try_again;
0373   using error::service_not_found;
0374 } // namespace resolver_errc
0375 } // namespace asio
0376 } // namespace boost
0377 
0378 #include <boost/asio/detail/pop_options.hpp>
0379 
0380 #undef BOOST_ASIO_NATIVE_ERROR
0381 #undef BOOST_ASIO_SOCKET_ERROR
0382 #undef BOOST_ASIO_NETDB_ERROR
0383 #undef BOOST_ASIO_GETADDRINFO_ERROR
0384 #undef BOOST_ASIO_WIN_OR_POSIX
0385 
0386 #if defined(BOOST_ASIO_HEADER_ONLY)
0387 # include <boost/asio/impl/error.ipp>
0388 #endif // defined(BOOST_ASIO_HEADER_ONLY)
0389 
0390 #endif // BOOST_ASIO_ERROR_HPP