Exception: OCI::Errors::ServiceError

Inherits:
HttpRequestBasedError show all
Defined in:
lib/oci/errors.rb

Overview

The base error for all requests that return error responses from the service.

Instance Attribute Summary collapse

Attributes inherited from HttpRequestBasedError

#message, #request_id, #request_made

Instance Method Summary collapse

Constructor Details

#initialize(status_code, service_code, request_id, message, request_made: nil) ⇒ ServiceError

Returns a new instance of ServiceError.



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/oci/errors.rb', line 61

def initialize(status_code, service_code, request_id, message, request_made: nil)
  @message = if message.nil? || message.strip.empty?
               "The service returned error code #{status_code}"
             else
               message.strip
             end
  super(message: @message, request_made: request_made)

  @status_code = status_code
  @service_code = service_code
  @request_id = request_id
end

Instance Attribute Details

#service_codeString (readonly)

A service-specific error code

Returns:

  • (String)


59
60
61
# File 'lib/oci/errors.rb', line 59

def service_code
  @service_code
end

#status_codeInteger (readonly)

HTTP status code (such as 200 or 404)

Returns:

  • (Integer)


54
55
56
# File 'lib/oci/errors.rb', line 54

def status_code
  @status_code
end

Instance Method Details

#to_sObject



74
75
76
77
# File 'lib/oci/errors.rb', line 74

def to_s
  "{ 'message': '#{message}', 'status': #{status_code}, " \
  "'code': '#{service_code}', 'opc-request-id': '#{request_id}' }"
end