Exception: OCI::Errors::ServiceError
- Inherits:
-
StandardError
- Object
- StandardError
- OCI::Errors::ServiceError
- Defined in:
- lib/oci/errors.rb
Overview
The base error for all requests that return error responses from the service.
Instance Attribute Summary collapse
-
#message ⇒ String
readonly
The error message.
-
#request_id ⇒ String
readonly
The request ID, taken from the opc-request-id header.
-
#service_code ⇒ String
readonly
A service-specific error code.
-
#status_code ⇒ Integer
readonly
HTTP status code (such as 200 or 404).
Instance Method Summary collapse
-
#initialize(status_code, service_code, request_id, message) ⇒ ServiceError
constructor
A new instance of ServiceError.
- #to_s ⇒ Object
Constructor Details
#initialize(status_code, service_code, request_id, message) ⇒ ServiceError
Returns a new instance of ServiceError.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/oci/errors.rb', line 27 def initialize(status_code, service_code, request_id, ) # 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 would go into an infinite loop @message = if .nil? || .strip.empty? "The service returned error code #{status_code}" else .strip end super @message @status_code = status_code @service_code = service_code @request_id = request_id end |
Instance Attribute Details
#message ⇒ String (readonly)
The error message
25 26 27 |
# File 'lib/oci/errors.rb', line 25 def @message end |
#request_id ⇒ String (readonly)
The request ID, taken from the opc-request-id header.
20 21 22 |
# File 'lib/oci/errors.rb', line 20 def request_id @request_id end |
#service_code ⇒ String (readonly)
A service-specific error code
15 16 17 |
# File 'lib/oci/errors.rb', line 15 def service_code @service_code end |
#status_code ⇒ Integer (readonly)
HTTP status code (such as 200 or 404)
10 11 12 |
# File 'lib/oci/errors.rb', line 10 def status_code @status_code end |
Instance Method Details
#to_s ⇒ Object
45 46 47 48 |
# File 'lib/oci/errors.rb', line 45 def to_s "{ 'message': '#{}', 'status': #{status_code}, " \ "'code': '#{service_code}', 'opc-request-id': '#{request_id}' }" end |