Exception: IbmAppconfigurationRubySdk::APIError
- Defined in:
- lib/ibm_appconfiguration_ruby_sdk/errors.rb
Overview
Raised for HTTP-level errors returned by the App Configuration service. Carries the HTTP status code and raw response body so callers can inspect the failure detail without parsing the exception message.
Direct Known Subclasses
AuthenticationError, InvalidRequestError, RateLimitError, ServerError
Instance Attribute Summary collapse
-
#http_body ⇒ Object
readonly
Returns the value of attribute http_body.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
Class Method Summary collapse
-
.from_status(status, body: nil, message: nil) ⇒ APIError
Factory — returns the most specific APIError subclass for the given status.
Instance Method Summary collapse
-
#initialize(msg = nil, http_status: nil, http_body: nil) ⇒ APIError
constructor
A new instance of APIError.
Constructor Details
#initialize(msg = nil, http_status: nil, http_body: nil) ⇒ APIError
Returns a new instance of APIError.
37 38 39 40 41 |
# File 'lib/ibm_appconfiguration_ruby_sdk/errors.rb', line 37 def initialize(msg = nil, http_status: nil, http_body: nil) super(msg) @http_status = http_status @http_body = http_body end |
Instance Attribute Details
#http_body ⇒ Object (readonly)
Returns the value of attribute http_body.
32 33 34 |
# File 'lib/ibm_appconfiguration_ruby_sdk/errors.rb', line 32 def http_body @http_body end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
32 33 34 |
# File 'lib/ibm_appconfiguration_ruby_sdk/errors.rb', line 32 def http_status @http_status end |
Class Method Details
.from_status(status, body: nil, message: nil) ⇒ APIError
Factory — returns the most specific APIError subclass for the given status.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ibm_appconfiguration_ruby_sdk/errors.rb', line 50 def self.from_status(status, body: nil, message: nil) klass = case status when 401 then AuthenticationError when 429 then RateLimitError when 400, 422 then InvalidRequestError when 500..599 then ServerError else APIError end klass.new( || "HTTP #{status}", http_status: status, http_body: body) end |