Exception: Walinko::ApiError
- Defined in:
- lib/walinko/errors.rb
Overview
Base class for every error response returned by the API. Carries the full diagnostic payload — HTTP status, server-side ‘error_code`, the `X-Request-Id` (handy for support tickets), and the optional `details` blob.
Direct Known Subclasses
AuthenticationError, BadRequestError, ConflictError, ForbiddenError, NotFoundError, RateLimitError, ServerError, TimeoutError, ValidationError
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
Instance Method Summary collapse
-
#initialize(message, http_status:, error_code: nil, request_id: nil, details: nil, body: nil) ⇒ ApiError
constructor
A new instance of ApiError.
- #inspect ⇒ Object
Constructor Details
#initialize(message, http_status:, error_code: nil, request_id: nil, details: nil, body: nil) ⇒ ApiError
Returns a new instance of ApiError.
28 29 30 31 32 33 34 35 36 |
# File 'lib/walinko/errors.rb', line 28 def initialize(, http_status:, error_code: nil, request_id: nil, details: nil, body: nil) super() @http_status = http_status @error_code = error_code @request_id = request_id @details = details || {} @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
26 27 28 |
# File 'lib/walinko/errors.rb', line 26 def body @body end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
26 27 28 |
# File 'lib/walinko/errors.rb', line 26 def details @details end |
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
26 27 28 |
# File 'lib/walinko/errors.rb', line 26 def error_code @error_code end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
26 27 28 |
# File 'lib/walinko/errors.rb', line 26 def http_status @http_status end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
26 27 28 |
# File 'lib/walinko/errors.rb', line 26 def request_id @request_id end |
Instance Method Details
#inspect ⇒ Object
38 39 40 41 42 43 |
# File 'lib/walinko/errors.rb', line 38 def inspect parts = [self.class.name, "status=#{http_status}"] parts << "code=#{error_code}" if error_code parts << "request_id=#{request_id}" if request_id "#<#{parts.join(' ')} message=#{.inspect}>" end |