OpenTTD Source
1.11.2
|
Abstraction of a network error where all implementation details of the error codes are encapsulated in this class and the abstraction layer. More...
#include <os_abstraction.h>
Public Member Functions | |
NetworkError (int error) | |
Construct the network error with the given error code. More... | |
bool | HasError () const |
Check whether an error was actually set. More... | |
bool | WouldBlock () const |
Check whether this error describes that the operation would block. More... | |
bool | IsConnectionReset () const |
Check whether this error describes a connection reset. More... | |
bool | IsConnectInProgress () const |
Check whether this error describes a connect is in progress. More... | |
const char * | AsString () const |
Get the string representation of the error message. More... | |
Static Public Member Functions | |
static NetworkError | GetLast () |
Get the last network error. More... | |
Private Attributes | |
int | error |
The underlying error number from errno or WSAGetLastError. | |
std::string | message |
The string representation of the error (set on first call to AsString). | |
Abstraction of a network error where all implementation details of the error codes are encapsulated in this class and the abstraction layer.
Definition at line 23 of file os_abstraction.h.
NetworkError::NetworkError | ( | int | error | ) |
Construct the network error with the given error code.
error | The error code. |
Definition at line 30 of file os_abstraction.cpp.
Referenced by GetLast().
const char * NetworkError::AsString | ( | ) | const |
Get the string representation of the error message.
Definition at line 79 of file os_abstraction.cpp.
References error, lastof, message, and seprintf().
Referenced by NetworkHTTPSocketHandler::Receive(), NetworkTCPSocketHandler::ReceivePacket(), NetworkUDPSocketHandler::SendPacket(), and NetworkTCPSocketHandler::SendPackets().
|
static |
Get the last network error.
Definition at line 116 of file os_abstraction.cpp.
References NetworkError().
Referenced by TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::AcceptClient(), ConnectLoopProc(), ListenLoopProc(), NetworkHTTPSocketHandler::Receive(), NetworkTCPSocketHandler::ReceivePacket(), NetworkUDPSocketHandler::SendPacket(), and NetworkTCPSocketHandler::SendPackets().
bool NetworkError::HasError | ( | ) | const |
Check whether an error was actually set.
Definition at line 107 of file os_abstraction.cpp.
References error.
bool NetworkError::IsConnectInProgress | ( | ) | const |
Check whether this error describes a connect is in progress.
Definition at line 66 of file os_abstraction.cpp.
References error.
bool NetworkError::IsConnectionReset | ( | ) | const |
Check whether this error describes a connection reset.
Definition at line 53 of file os_abstraction.cpp.
References error.
Referenced by NetworkHTTPSocketHandler::Receive(), and NetworkTCPSocketHandler::ReceivePacket().
bool NetworkError::WouldBlock | ( | ) | const |
Check whether this error describes that the operation would block.
Definition at line 38 of file os_abstraction.cpp.
References error.
Referenced by NetworkHTTPSocketHandler::Receive(), NetworkTCPSocketHandler::ReceivePacket(), and NetworkTCPSocketHandler::SendPackets().