deluge/libtorrent/include/asio/error.hpp

258 lines
6.5 KiB
C++
Raw Normal View History

2007-07-04 08:24:30 +00:00
//
// error.hpp
// ~~~~~~~~~
//
2008-03-08 23:47:38 +00:00
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
2007-07-04 08:24:30 +00:00
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_ERROR_HPP
#define ASIO_ERROR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/push_options.hpp"
#include "asio/detail/push_options.hpp"
#include <cerrno>
#include <boost/config.hpp>
#include "asio/detail/pop_options.hpp"
#include "asio/error_code.hpp"
#include "asio/detail/socket_types.hpp"
#if defined(GENERATING_DOCUMENTATION)
/// INTERNAL ONLY.
# define ASIO_NATIVE_ERROR(e) implementation_defined
/// INTERNAL ONLY.
# define ASIO_SOCKET_ERROR(e) implementation_defined
/// INTERNAL ONLY.
# define ASIO_NETDB_ERROR(e) implementation_defined
/// INTERNAL ONLY.
# define ASIO_GETADDRINFO_ERROR(e) implementation_defined
/// INTERNAL ONLY.
# define ASIO_WIN_OR_POSIX(e_win, e_posix) implementation_defined
#elif defined(BOOST_WINDOWS) || defined(__CYGWIN__)
2007-09-21 00:55:58 +00:00
# define ASIO_NATIVE_ERROR(e) e
# define ASIO_SOCKET_ERROR(e) WSA ## e
# define ASIO_NETDB_ERROR(e) WSA ## e
# define ASIO_GETADDRINFO_ERROR(e) WSA ## e
2007-07-04 08:24:30 +00:00
# define ASIO_WIN_OR_POSIX(e_win, e_posix) e_win
#else
2007-09-21 00:55:58 +00:00
# define ASIO_NATIVE_ERROR(e) e
# define ASIO_SOCKET_ERROR(e) e
# define ASIO_NETDB_ERROR(e) e
# define ASIO_GETADDRINFO_ERROR(e) e
2007-07-04 08:24:30 +00:00
# define ASIO_WIN_OR_POSIX(e_win, e_posix) e_posix
#endif
namespace asio {
2007-09-21 00:55:58 +00:00
namespace error {
2007-07-04 08:24:30 +00:00
2007-09-21 00:55:58 +00:00
enum basic_errors
2007-07-04 08:24:30 +00:00
{
/// Permission denied.
2007-09-21 00:55:58 +00:00
access_denied = ASIO_SOCKET_ERROR(EACCES),
2007-07-04 08:24:30 +00:00
/// Address family not supported by protocol.
2007-09-21 00:55:58 +00:00
address_family_not_supported = ASIO_SOCKET_ERROR(EAFNOSUPPORT),
2007-07-04 08:24:30 +00:00
/// Address already in use.
2007-09-21 00:55:58 +00:00
address_in_use = ASIO_SOCKET_ERROR(EADDRINUSE),
2007-07-04 08:24:30 +00:00
/// Transport endpoint is already connected.
2007-09-21 00:55:58 +00:00
already_connected = ASIO_SOCKET_ERROR(EISCONN),
2007-07-04 08:24:30 +00:00
/// Operation already in progress.
2007-09-21 00:55:58 +00:00
already_started = ASIO_SOCKET_ERROR(EALREADY),
2007-07-04 08:24:30 +00:00
2008-02-10 22:07:23 +00:00
/// Broken pipe.
broken_pipe = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_BROKEN_PIPE),
ASIO_NATIVE_ERROR(EPIPE)),
2007-07-04 08:24:30 +00:00
/// A connection has been aborted.
2007-09-21 00:55:58 +00:00
connection_aborted = ASIO_SOCKET_ERROR(ECONNABORTED),
2007-07-04 08:24:30 +00:00
/// Connection refused.
2007-09-21 00:55:58 +00:00
connection_refused = ASIO_SOCKET_ERROR(ECONNREFUSED),
2007-07-04 08:24:30 +00:00
/// Connection reset by peer.
2007-09-21 00:55:58 +00:00
connection_reset = ASIO_SOCKET_ERROR(ECONNRESET),
2007-07-04 08:24:30 +00:00
/// Bad file descriptor.
2007-09-21 00:55:58 +00:00
bad_descriptor = ASIO_SOCKET_ERROR(EBADF),
2007-07-04 08:24:30 +00:00
/// Bad address.
2007-09-21 00:55:58 +00:00
fault = ASIO_SOCKET_ERROR(EFAULT),
2007-07-04 08:24:30 +00:00
/// No route to host.
2007-09-21 00:55:58 +00:00
host_unreachable = ASIO_SOCKET_ERROR(EHOSTUNREACH),
2007-07-04 08:24:30 +00:00
/// Operation now in progress.
2007-09-21 00:55:58 +00:00
in_progress = ASIO_SOCKET_ERROR(EINPROGRESS),
2007-07-04 08:24:30 +00:00
/// Interrupted system call.
2007-09-21 00:55:58 +00:00
interrupted = ASIO_SOCKET_ERROR(EINTR),
2007-07-04 08:24:30 +00:00
/// Invalid argument.
2007-09-21 00:55:58 +00:00
invalid_argument = ASIO_SOCKET_ERROR(EINVAL),
2007-07-04 08:24:30 +00:00
/// Message too long.
2007-09-21 00:55:58 +00:00
message_size = ASIO_SOCKET_ERROR(EMSGSIZE),
2007-07-04 08:24:30 +00:00
/// Network is down.
2007-09-21 00:55:58 +00:00
network_down = ASIO_SOCKET_ERROR(ENETDOWN),
2007-07-04 08:24:30 +00:00
/// Network dropped connection on reset.
2007-09-21 00:55:58 +00:00
network_reset = ASIO_SOCKET_ERROR(ENETRESET),
2007-07-04 08:24:30 +00:00
/// Network is unreachable.
2007-09-21 00:55:58 +00:00
network_unreachable = ASIO_SOCKET_ERROR(ENETUNREACH),
2007-07-04 08:24:30 +00:00
/// Too many open files.
2007-09-21 00:55:58 +00:00
no_descriptors = ASIO_SOCKET_ERROR(EMFILE),
2007-07-04 08:24:30 +00:00
/// No buffer space available.
2007-09-21 00:55:58 +00:00
no_buffer_space = ASIO_SOCKET_ERROR(ENOBUFS),
2007-07-04 08:24:30 +00:00
/// Cannot allocate memory.
2007-09-21 00:55:58 +00:00
no_memory = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_OUTOFMEMORY),
ASIO_NATIVE_ERROR(ENOMEM)),
2007-07-04 08:24:30 +00:00
/// Operation not permitted.
2007-09-21 00:55:58 +00:00
no_permission = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_ACCESS_DENIED),
ASIO_NATIVE_ERROR(EPERM)),
2007-07-04 08:24:30 +00:00
/// Protocol not available.
2007-09-21 00:55:58 +00:00
no_protocol_option = ASIO_SOCKET_ERROR(ENOPROTOOPT),
2007-07-04 08:24:30 +00:00
/// Transport endpoint is not connected.
2007-09-21 00:55:58 +00:00
not_connected = ASIO_SOCKET_ERROR(ENOTCONN),
2007-07-04 08:24:30 +00:00
/// Socket operation on non-socket.
2007-09-21 00:55:58 +00:00
not_socket = ASIO_SOCKET_ERROR(ENOTSOCK),
2007-07-04 08:24:30 +00:00
/// Operation cancelled.
2007-09-21 00:55:58 +00:00
operation_aborted = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_OPERATION_ABORTED),
ASIO_NATIVE_ERROR(ECANCELED)),
2007-07-04 08:24:30 +00:00
/// Operation not supported.
2007-09-21 00:55:58 +00:00
operation_not_supported = ASIO_SOCKET_ERROR(EOPNOTSUPP),
2007-07-04 08:24:30 +00:00
/// Cannot send after transport endpoint shutdown.
2007-09-21 00:55:58 +00:00
shut_down = ASIO_SOCKET_ERROR(ESHUTDOWN),
2007-07-04 08:24:30 +00:00
/// Connection timed out.
2007-09-21 00:55:58 +00:00
timed_out = ASIO_SOCKET_ERROR(ETIMEDOUT),
2007-07-04 08:24:30 +00:00
/// Resource temporarily unavailable.
2007-09-21 00:55:58 +00:00
try_again = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_RETRY),
ASIO_NATIVE_ERROR(EAGAIN)),
2007-07-04 08:24:30 +00:00
/// The socket is marked non-blocking and the requested operation would block.
2007-09-21 00:55:58 +00:00
would_block = ASIO_SOCKET_ERROR(EWOULDBLOCK)
2007-07-04 08:24:30 +00:00
};
2007-09-21 00:55:58 +00:00
enum netdb_errors
{
/// Host not found (authoritative).
host_not_found = ASIO_NETDB_ERROR(HOST_NOT_FOUND),
2007-09-21 00:22:38 +00:00
2007-09-21 00:55:58 +00:00
/// Host not found (non-authoritative).
host_not_found_try_again = ASIO_NETDB_ERROR(TRY_AGAIN),
2007-09-21 00:22:38 +00:00
2007-09-21 00:55:58 +00:00
/// The query is valid but does not have associated address data.
no_data = ASIO_NETDB_ERROR(NO_DATA),
2007-09-21 00:22:38 +00:00
2007-09-21 00:55:58 +00:00
/// A non-recoverable error occurred.
no_recovery = ASIO_NETDB_ERROR(NO_RECOVERY)
};
2007-09-21 00:22:38 +00:00
2007-09-21 00:55:58 +00:00
enum addrinfo_errors
{
/// The service is not supported for the given socket type.
service_not_found = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(WSATYPE_NOT_FOUND),
ASIO_GETADDRINFO_ERROR(EAI_SERVICE)),
2007-09-21 00:22:38 +00:00
2007-09-21 00:55:58 +00:00
/// The socket type is not supported.
socket_type_not_supported = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(WSAESOCKTNOSUPPORT),
ASIO_GETADDRINFO_ERROR(EAI_SOCKTYPE))
};
2007-09-21 00:22:38 +00:00
2007-09-21 00:55:58 +00:00
enum misc_errors
{
/// Already open.
already_open = 1,
2007-09-21 00:22:38 +00:00
2007-09-21 00:55:58 +00:00
/// End of file or stream.
eof,
2007-09-21 00:22:38 +00:00
2007-09-21 00:55:58 +00:00
/// Element not found.
2008-02-10 22:07:23 +00:00
not_found,
/// The descriptor cannot fit into the select system call's fd_set.
fd_set_failure
2007-09-21 00:55:58 +00:00
};
2007-09-21 00:22:38 +00:00
2007-11-23 23:36:34 +00:00
enum ssl_errors
{
};
2007-09-21 00:55:58 +00:00
// boostify: error category definitions go here.
2007-09-21 00:22:38 +00:00
2007-09-21 00:55:58 +00:00
inline asio::error_code make_error_code(basic_errors e)
{
2007-11-23 23:36:34 +00:00
return asio::error_code(
static_cast<int>(e), get_system_category());
2007-09-21 00:55:58 +00:00
}
2007-09-21 00:22:38 +00:00
2007-09-21 00:55:58 +00:00
inline asio::error_code make_error_code(netdb_errors e)
{
2007-11-23 23:36:34 +00:00
return asio::error_code(
static_cast<int>(e), get_netdb_category());
2007-09-21 00:55:58 +00:00
}
2007-09-21 00:22:38 +00:00
2007-09-21 00:55:58 +00:00
inline asio::error_code make_error_code(addrinfo_errors e)
{
2007-11-23 23:36:34 +00:00
return asio::error_code(
static_cast<int>(e), get_addrinfo_category());
2007-09-21 00:55:58 +00:00
}
2007-09-21 00:22:38 +00:00
2007-09-21 00:55:58 +00:00
inline asio::error_code make_error_code(misc_errors e)
2007-07-04 08:24:30 +00:00
{
2007-11-23 23:36:34 +00:00
return asio::error_code(
static_cast<int>(e), get_misc_category());
}
inline asio::error_code make_error_code(ssl_errors e)
{
return asio::error_code(
static_cast<int>(e), get_ssl_category());
2007-09-21 00:55:58 +00:00
}
2007-07-04 08:24:30 +00:00
2007-09-21 00:55:58 +00:00
} // namespace error
2007-07-04 08:24:30 +00:00
} // namespace asio
#undef ASIO_NATIVE_ERROR
#undef ASIO_SOCKET_ERROR
#undef ASIO_NETDB_ERROR
#undef ASIO_GETADDRINFO_ERROR
#undef ASIO_WIN_OR_POSIX
#include "asio/impl/error_code.ipp"
#include "asio/detail/pop_options.hpp"
#endif // ASIO_ERROR_HPP