class OCI::Errors::NetworkError

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.

Attributes

code[R]

Error code, which is mapped to Net::HTTPResponse's code.to_i or 0 if the issue was reported by an exception.

@return [Integer]

response_received[R]

The response received for the request, if any

@return [Net::HTTPResponse]

Public Class Methods

new(message, code, request_made: nil, response_received: nil) click to toggle source
Calls superclass method OCI::Errors::HttpRequestBasedError::new
# File lib/oci/errors.rb, line 101
def initialize(message, code, request_made: nil, response_received: nil)
  super(message: 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

Public Instance Methods

to_s() click to toggle source
# File lib/oci/errors.rb, line 112
def to_s
  response_body = response_received.body unless response_received.nil?

  "{ 'message': '#{message}', 'status': #{code}, " \
  "'opc-request-id': '#{request_id}', 'response-body': '#{response_body}' }"
end