Exception: OCI::Errors::HttpRequestBasedError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/oci/errors.rb

Overview

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 ServiceError and NetworkError, may have stronger definitions around what circumstances caused the error to be thrown.

Direct Known Subclasses

NetworkError, ResponseParsingError, ServiceError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message: nil, request_made: nil) ⇒ HttpRequestBasedError

Returns a new instance of HttpRequestBasedError.



34
35
36
37
38
39
40
41
42
# 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

Instance Attribute Details

#messageString (readonly)

The error message

Returns:

  • (String)


32
33
34
# File 'lib/oci/errors.rb', line 32

def message
  @message
end

#request_idString (readonly)

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)

Returns:

  • (String)


27
28
29
# File 'lib/oci/errors.rb', line 27

def request_id
  @request_id
end

#request_madeNet::HTTPRequest (readonly)

The request which was made

Returns:

  • (Net::HTTPRequest)


20
21
22
# File 'lib/oci/errors.rb', line 20

def request_made
  @request_made
end

Instance Method Details

#to_sObject



44
45
46
# File 'lib/oci/errors.rb', line 44

def to_s
  "{ 'message': '#{message}', 'opc-request-id': '#{request_id}' }"
end