|
OpenTTD Source 20251117-master-g7398d2e290
|
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, std::string_view message={}) | |
| Construct the network error with the given error code. | |
| bool | HasError () const |
| Check whether an error was actually set. | |
| bool | WouldBlock () const |
| Check whether this error describes that the operation would block. | |
| bool | IsConnectionReset () const |
| Check whether this error describes a connection reset. | |
| bool | IsConnectInProgress () const |
| Check whether this error describes a connect is in progress. | |
| std::string_view | AsString () const |
| Get the string representation of the error message. | |
Static Public Member Functions | |
| static NetworkError | GetLast () |
| Get the last network error. | |
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 21 of file os_abstraction.h.
| NetworkError::NetworkError | ( | int | error, |
| std::string_view | message = {} |
||
| ) |
Construct the network error with the given error code.
| error | The error code. |
| message | The error message. Leave empty to determine this automatically based on the error number. |
Definition at line 32 of file os_abstraction.cpp.
| std::string_view NetworkError::AsString | ( | ) | const |
Get the string representation of the error message.
Definition at line 81 of file os_abstraction.cpp.
References error, FS2OTTD(), and message.
Referenced by TCPConnecter::CheckActivity(), TCPConnecter::Connect(), NetworkTCPSocketHandler::ReceivePacket(), NetworkUDPSocketHandler::SendPacket(), and NetworkTCPSocketHandler::SendPackets().
|
static |
Get the last network error.
Definition at line 119 of file os_abstraction.cpp.
Referenced by TCPConnecter::CheckActivity(), TCPConnecter::Connect(), NetworkAddress::GetPeerAddress(), NetworkAddress::GetSockAddress(), ListenLoopProc(), NetworkTCPSocketHandler::ReceivePacket(), NetworkUDPSocketHandler::SendPacket(), and NetworkTCPSocketHandler::SendPackets().
| bool NetworkError::HasError | ( | ) | const |
Check whether an error was actually set.
Definition at line 110 of file os_abstraction.cpp.
References error.
Referenced by TCPConnecter::CheckActivity().
| bool NetworkError::IsConnectInProgress | ( | ) | const |
Check whether this error describes a connect is in progress.
Definition at line 68 of file os_abstraction.cpp.
References error.
| bool NetworkError::IsConnectionReset | ( | ) | const |
Check whether this error describes a connection reset.
Definition at line 55 of file os_abstraction.cpp.
References error.
Referenced by NetworkTCPSocketHandler::ReceivePacket().
| bool NetworkError::WouldBlock | ( | ) | const |
Check whether this error describes that the operation would block.
Definition at line 40 of file os_abstraction.cpp.
References error.
Referenced by NetworkTCPSocketHandler::ReceivePacket(), and NetworkTCPSocketHandler::SendPackets().
|
private |
The underlying error number from errno or WSAGetLastError.
Definition at line 23 of file os_abstraction.h.
Referenced by AsString(), HasError(), IsConnectInProgress(), IsConnectionReset(), and WouldBlock().
|
mutableprivate |
The string representation of the error (set on first call to AsString).
Definition at line 24 of file os_abstraction.h.
Referenced by AsString().