class OCI::Errors::ResponseParsingError

The base error for issues related to parsing the response received from the service. The {#response_body} can be inspected for the data which failed to parse and the {#cause} of this error can be inspected for the underlying parsing error which occurred

Attributes

response_received[R]

The response received for the request, and whose body we failed to parse

@return [Net::HTTPResponse]

Public Class Methods

new(message: 'Failed to parse response', request_made:, response_received:) click to toggle source
Calls superclass method OCI::Errors::HttpRequestBasedError::new
# File lib/oci/errors.rb, line 129
def initialize(message: 'Failed to parse response', request_made:, response_received:)
  raise 'A message must be provided' if message.nil? || message.strip.empty?
  raise 'The request made must be provided' if request_made.nil?
  raise 'The response received must be provided' if response_received.nil?

  super(message: message, request_made: request_made)
  @response_received = response_received
  @request_id = @response_received['opc-request-id'] unless @response_received['opc-request-id'].nil?
end

Public Instance Methods

response_body() click to toggle source

The response body which we failed to parse

@return [String]

# File lib/oci/errors.rb, line 142
def response_body
  response_received.body
end
status_code() click to toggle source

The status code of the response (e.g. 200)

@return [Integer]

# File lib/oci/errors.rb, line 149
def status_code
  response_received.code.to_i
end
to_s() click to toggle source
# File lib/oci/errors.rb, line 153
def to_s
  "{ 'message': '#{message}', 'status': #{status_code}, " \
  "'opc-request-id': '#{request_id}', 'response-body': '#{response_body}' }"
end