Exception: OCI::Errors::HttpRequestBasedError
- Inherits:
-
StandardError
- Object
- StandardError
- OCI::Errors::HttpRequestBasedError
- 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
Instance Attribute Summary collapse
-
#message ⇒ String
readonly
The error message.
-
#request_id ⇒ String
readonly
The request ID from the opc-request-id header.
-
#request_made ⇒ Net::HTTPRequest
readonly
The request which was made.
Instance Method Summary collapse
-
#initialize(message: nil, request_made: nil) ⇒ HttpRequestBasedError
constructor
A new instance of HttpRequestBasedError.
- #to_s ⇒ Object
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 = @request_made = request_made @request_id = @request_made['opc-request-id'] unless @request_made.nil? end |
Instance Attribute Details
#message ⇒ String (readonly)
The error message
32 33 34 |
# File 'lib/oci/errors.rb', line 32 def @message end |
#request_id ⇒ String (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)
27 28 29 |
# File 'lib/oci/errors.rb', line 27 def request_id @request_id end |
#request_made ⇒ Net::HTTPRequest (readonly)
The request which was made
20 21 22 |
# File 'lib/oci/errors.rb', line 20 def request_made @request_made end |
Instance Method Details
#to_s ⇒ Object
44 45 46 |
# File 'lib/oci/errors.rb', line 44 def to_s "{ 'message': '#{}', 'opc-request-id': '#{request_id}' }" end |