4#ifndef GREM_NETWORKING_ERROR_HPP
5#define GREM_NETWORKING_ERROR_HPP
13#include <system_error>
27 explicit
Error(std::error_code errorCode)
28 :
Error(errorCode.message()) {}
47struct std::is_error_code_enum<
grem::networking::WSAError> : std::true_type {};
54struct WSAErrorCategory : std::error_category {
55 [[nodiscard]] GREM_API(networking)
const char* name() const noexcept override;
56 [[nodiscard]] GREM_API(networking) std::
string message(
int condition) const override;
63 [[nodiscard]] static const WSAErrorCategory& getInstance() noexcept {
64 static const WSAErrorCategory category{};
69 WSAErrorCategory() noexcept = default;
80[[nodiscard]] inline std::error_code make_error_code(WSAError error) {
81 return std::error_code{
static_cast<int>(error.value), WSAErrorCategory::getInstance()};
88namespace grem::networking {
105 ADDRFAMILY = EAI_ADDRFAMILY,
107 INPROGRESS = EAI_INPROGRESS,
108 CANCELED = EAI_CANCELED,
109 NOTCANCELED = EAI_NOTCANCELED,
110 ALLDONE = EAI_ALLDONE,
112 IDN_ENCODE = EAI_IDN_ENCODE,
127struct EndpointErrorCategory : std::error_category {
136 [[nodiscard]] static const EndpointErrorCategory&
getInstance() noexcept {
137 static const EndpointErrorCategory category{};
178struct SocketErrorCategory : std::error_category {
181 [[nodiscard]] GREM_API(
networking)
bool equivalent(const std::error_code& code,
int condition) const noexcept override;
188 [[nodiscard]] static const SocketErrorCategory&
getInstance() noexcept {
189 static const SocketErrorCategory category{};
Base exception type for runtime errors.
Definition Error.hpp:38
Definition Endpoint.hpp:28
std::error_code make_error_code(EndpointError error)
Create a std::error_code from an EndpointError value.
Definition Error.hpp:153
std::error_condition make_error_condition(SocketError error)
Create a std::error_condition from a SocketError value.
Definition Error.hpp:217
SocketError
Error condition type for error codes originating from the Socket API.
Definition Error.hpp:160
@ DISCONNECTED
The socket disconnected.
Definition Error.hpp:164
@ FAILED
The operation failed.
Definition Error.hpp:165
@ WAIT
Try again later.
Definition Error.hpp:162
@ PARTIAL
The data was partially transmitted.
Definition Error.hpp:163
EndpointError
Error code value type for error codes originating from the getaddrinfo() API.
Definition Error.hpp:94
@ SOCKTYPE
EAI_SOCKTYPE.
Definition Error.hpp:103
@ FAMILY
EAI_FAMILY.
Definition Error.hpp:98
@ AGAIN
EAI_AGAIN.
Definition Error.hpp:95
@ MEMORY
EAI_MEMORY.
Definition Error.hpp:99
@ BADFLAGS
EAI_BADFLAGS.
Definition Error.hpp:96
@ NONAME
EAI_NONAME.
Definition Error.hpp:101
@ FAIL
EAI_FAIL.
Definition Error.hpp:97
@ NODATA
EAI_NODATA.
Definition Error.hpp:100
@ SERVICE
EAI_SERVICE.
Definition Error.hpp:102
Error category type for error codes originating from the getaddrinfo() API.
Definition Error.hpp:127
std::string message(int condition) const override
const char * name() const noexcept override
static const EndpointErrorCategory & getInstance() noexcept
Get the canonical global instance of this error category.
Definition Error.hpp:136
static std::error_code getLastErrorCode() noexcept
Error(std::error_code errorCode)
Definition Error.hpp:27
Error category type for error codes originating from the Socket API.
Definition Error.hpp:178
static const SocketErrorCategory & getInstance() noexcept
Get the canonical global instance of this error category.
Definition Error.hpp:188
bool equivalent(const std::error_code &code, int condition) const noexcept override
std::string message(int condition) const override
const char * name() const noexcept override