class OCI::Errors::HttpRequestBasedError

Represents an error which was generated somewhere during the process of making a HTTP request to an OCI service. This error contains the raw request and also exposes some convenience properties such as the opc-request-id for the request. This error makes no guarantee or inference about whether the error was generated based on a response from an OCI service, whether there was a network issue etc.

When used directly, the {#cause} of the error should be inspected for the original error which resulted in this one being thrown.

Subclasses, such as {OCI::Errors::ServiceError} and {OCI::Errors::NetworkError}, may have stronger definitions around what circumstances caused the error to be thrown.

Attributes

message[R]

The error message

@return [String]

request_id[R]

The request ID from the opc-request-id header. This could be the request ID returned from the service or, if there was no opc-request-id in the response, it will be the opc-request-id set client-side by the caller or the SDK (if there was no explicit caller-provided opc-request-id)

@return [String]

request_made[R]

The request which was made

@return [Net::HTTPRequest]

Public Class Methods

new(message: nil, request_made: nil) click to toggle source
# File lib/oci/errors.rb, line 34
def initialize(message: nil, request_made: nil)
  # We need to mask the message attribute here as otherwise we use StandardError's
  # implementation, which calls to_s and so referencing "message" in our to_s in
  # this class (and subclasses) would go into an infinite loop
  @message = message

  @request_made = request_made
  @request_id = @request_made['opc-request-id'] unless @request_made.nil?
end

Public Instance Methods

to_s() click to toggle source
# File lib/oci/errors.rb, line 44
def to_s
  "{ 'message': '#{message}', 'opc-request-id': '#{request_id}' }"
end