LIBWIRE
Next-generation C++17 networking library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Enumerations | Functions
libwire::error Namespace Reference

Namespace with platform-independent error codes. More...

Enumerations

enum  dns_condition { host_not_found, host_not_found_try_again, no_address }
 
enum  generic : int8_t { generic::no_destination = -1, generic::no_resources = -2, generic::disconnected = -3 }
 These values combine together different error codes to simplify error handling where reaction to different errors is same. More...
 
enum  system_condition : uint8_t {
  success = 0, unknown = 255, unexpected = 254, invalid_argument = 1,
  permission_denied, operation_not_permitted, try_again, in_progress,
  already, interrupted, out_of_memory, process_limit_reached,
  system_limit_reached, protocol_not_supported, connection_refused, connection_reset,
  broken_pipe, shutdown, already_in_use, address_not_available,
  connection_aborted, network_unreachable, host_down, host_unreachable,
  timeout, not_connected, end_of_file
}
 

Functions

std::error_category & dns_category ()
 Obtain reference to static instance of category for DNS errors. More...
 
std::error_condition make_error_condition (generic)
 
std::error_condition make_error_condition (system_condition)
 
std::error_condition make_error_condition (dns_condition)
 
std::error_category & system_category ()
 Obtain reference to static instance of category for various network and socket errors. More...
 

Detailed Description

Namespace with platform-independent error codes.

Note
Prefer to reference error conditions without enumeration name, usually error names is self-explanatory. I.e. error::success, not error::generic_condition::success.

Enumeration Type Documentation

Enumerator
host_not_found 

Requested host doesn't exists.

host_not_found_try_again 

Requested host doesn't exists, but DNS server answer is non-authoritative.

no_address 

Requested host exists, but does not have any addresses defined.

Definition at line 261 of file error.hpp.

enum libwire::error::generic : int8_t
strong

These values combine together different error codes to simplify error handling where reaction to different errors is same.

Enumerator
no_destination 

Failed to connect to destination server.

Possible reasons:

  • No server running on specified port (connection refused)
  • IP address is invalid
  • Host is known to be down
  • Host is unreachable
  • Timed out
no_resources 

Out of resources.

Possible reasons:

  • Out of memory
  • Limitation reached
disconnected 

Disconnected, either forcibly or gracefully.

Definition at line 53 of file error.hpp.

Enumerator
success 

Operation completed successfully.

unknown 

Error code not mapped to any other condition.

Note
std::error_code::message may still return readable description.
unexpected 

Error code that should not occur on normal library operation.

Causes program termination in debug builds.

Report it as a bug with std::error_code::message output.

invalid_argument 

Invalid argument passed to function.

Note
This error condition is mapped to multiple platform error codes so you can use it to detect any invalid argument.
permission_denied 

Access to resource disallowed.

Do not confuse with operation_not_permitted.

Usually occurs when you try to bind to privileged (1-1024) port on POSIX systems while running as non-privileged user.

Some sandboxing mechanisms can also restrict access to networking, so it's better to ignore this error code if access to resource is not required for program operation.

operation_not_permitted 

Operation disallowed.

Do not confuse with permission_denied.

try_again 

Underlying implementation reported temporary failure -OR- non-blocking operation would block.

in_progress 

Non-blocking operation started, but not completed yet.

already 

Previous non-blocking operation still running.

interrupted 

System call interrupted by signal (POSIX-specific).

out_of_memory 

Operating system out of memory.

process_limit_reached 

Per-process limitation reached.

Can be emitted, for example, when you try to open more sockets than allowed.

system_limit_reached 

System-wide limitation reached.

Can be emitted, for example, when you try to open more sockets than allowed.

protocol_not_supported 

Requested protocol is not supported.

Typically reported when system doesn't have any IPv6-capable network interfaces.

connection_refused 

Reported by tcp::socket::connect to indicate that no service is listening on specified port.

connection_reset 

RST segment received (TCP).

broken_pipe 

Destination finished transmission.

shutdown 

Cannot send after transport endpoint shutdown.

already_in_use 

Reported by listener::bind or listen to indicate that port is already used.

address_not_available 

Reported by listener::bind to indicate that interface with specified address doesn't exists or not local.

connection_aborted 

A connection has been aborted.

network_unreachable 

Network is unreachable.

host_down 

Host is known to be down.

host_unreachable 

Host destination is unreachable.

timeout 

Timed out while trying to perform operation.

not_connected 

Attempt to use not connected socket.

end_of_file 

Remote side of connection finished transmission.

Definition at line 86 of file error.hpp.

Function Documentation

std::error_category& libwire::error::dns_category ( )

Obtain reference to static instance of category for DNS errors.

name() will be "dns".

std::error_condition libwire::error::make_error_condition ( generic  )
std::error_condition libwire::error::make_error_condition ( system_condition  )
std::error_condition libwire::error::make_error_condition ( dns_condition  )
std::error_category& libwire::error::system_category ( )

Obtain reference to static instance of category for various network and socket errors.

name() will be "system".