Exception: OCI::Errors::NetworkError
- Inherits:
-
HttpRequestBasedError
- Object
- StandardError
- HttpRequestBasedError
- OCI::Errors::NetworkError
- Defined in:
- lib/oci/errors.rb
Overview
The base error for issues which are likely to be network related, rather than an application issue. This is defined as:
* Requests which were sent from the SDK but the outcome was not a response from an OCI service. Further examples of include:
* Gateway timeouts
* Read or connection timeouts
* Any {Errno} exception which was generated by making the request
* Requests which resulted in a HTTP 408 (timeout)
The #cause of this error can be inspected to see if there was an original error which resulted in this one being thrown.
Instance Attribute Summary collapse
-
#code ⇒ Integer
readonly
Error code, which is mapped to Net::HTTPResponse’s code.to_i or 0 if the issue was reported by an exception.
-
#response_received ⇒ Net::HTTPResponse
readonly
The response received for the request, if any.
Attributes inherited from HttpRequestBasedError
#message, #request_id, #request_made
Instance Method Summary collapse
-
#initialize(message, code, request_made: nil, response_received: nil) ⇒ NetworkError
constructor
A new instance of NetworkError.
- #to_s ⇒ Object
Constructor Details
#initialize(message, code, request_made: nil, response_received: nil) ⇒ NetworkError
Returns a new instance of NetworkError.
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/oci/errors.rb', line 100 def initialize(, code, request_made: nil, response_received: nil) super(message: , request_made: request_made) @code = code @response_received = response_received # If we have a request ID from the response then use that, otherwise just take the one from the # request (the superclass constructor sets the opc-request-id from the request by default) response_req_id = @response_received['opc-request-id'] unless @response_received.nil? @request_id = response_req_id unless response_req_id.nil? end |
Instance Attribute Details
#code ⇒ Integer (readonly)
Error code, which is mapped to Net::HTTPResponse’s code.to_i or 0 if the issue was reported by an exception.
93 94 95 |
# File 'lib/oci/errors.rb', line 93 def code @code end |
#response_received ⇒ Net::HTTPResponse (readonly)
The response received for the request, if any
98 99 100 |
# File 'lib/oci/errors.rb', line 98 def response_received @response_received end |
Instance Method Details
#to_s ⇒ Object
111 112 113 114 115 116 |
# File 'lib/oci/errors.rb', line 111 def to_s response_body = response_received.body unless response_received.nil? "{ 'message': '#{}', 'status': #{code}, " \ "'opc-request-id': '#{request_id}', 'response-body': '#{response_body}' }" end |