Exception: X::NetworkError
- Includes:
- RequestContext
- Defined in:
- x-core/lib/x/core/errors/network_error.rb
Overview
Raised when a request never reached the API, or its response never arrived
It stands for every error a socket raises: a refused, reset, or dropped connection, a host that cannot be resolved, a TLS handshake that failed, a proxy that refused to open a tunnel, and the open, read, and write timeouts of the client. A client sends an idempotent request again only after one that never reached the API, such as a refused connection or a timeout opening it, and leaves the rest, and any POST, to the caller, since whether the API acted on it is unknown; see Client#initialize.
The message names the request that failed, and #http_method and #uri read it, since nothing of a request that got no response is left to read it from.
Instance Method Summary collapse
-
#http_method ⇒ Symbol?
The HTTP method the request that failed was sent with.
-
#initialize(message = nil, http_method: nil, uri: nil) ⇒ NetworkError
constructor
Initialize a new NetworkError.
-
#uri ⇒ URI::Generic?
The URI the request that failed was sent to.
Constructor Details
#initialize(message = nil, http_method: nil, uri: nil) ⇒ NetworkError
Initialize a new NetworkError
Public, so that code that rescues a NetworkError can be tested with one built by hand, as Connection builds one for the errors a socket raises, or raised with no message, as any exception is. The error names the request, when given its method and URI, as x-core names the request that failed.
53 54 55 56 |
# File 'x-core/lib/x/core/errors/network_error.rb', line 53 def initialize( = nil, http_method: nil, uri: nil) name_request(http_method, uri) super( && ()) end |
Instance Method Details
#http_method ⇒ Symbol?
The HTTP method the request that failed was sent with
|
|
# File 'x-core/lib/x/core/errors/network_error.rb', line 26
|
#uri ⇒ URI::Generic?
The URI the request that failed was sent to
|
|
# File 'x-core/lib/x/core/errors/network_error.rb', line 26
|