Exception: Dinie::APIStatusError
- Defined in:
- lib/dinie/runtime/errors.rb
Overview
The API returned a non-2xx response. Base of the openapi-mirrored marker catalog (‘generated/errors/registry.rb`); the markers are empty subclasses and inherit this constructor, so Internal::Errors.from_response can build any of them uniformly.
Direct Known Subclasses
AuthError, BadRequestError, ConflictError, NotFoundError, PermissionDeniedError, RateLimitError, ServerError, ValidationError
Instance Attribute Summary collapse
-
#body ⇒ Hash, ...
readonly
Parsed Problem Details, raw body text, or nil.
-
#detail ⇒ String?
readonly
Problem Details ‘detail`.
-
#headers ⇒ Hash
readonly
Raw response headers.
-
#instance ⇒ String?
readonly
Problem Details ‘instance`.
-
#status ⇒ Integer
readonly
HTTP status code.
-
#title ⇒ String?
readonly
Problem Details ‘title`.
-
#type ⇒ String?
readonly
Problem Details ‘type` URL.
Attributes inherited from APIError
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status:, body:, headers:, request_id: nil) ⇒ APIStatusError
constructor
A new instance of APIStatusError.
Constructor Details
#initialize(status:, body:, headers:, request_id: nil) ⇒ APIStatusError
Returns a new instance of APIStatusError.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/dinie/runtime/errors.rb', line 73 def initialize(status:, body:, headers:, request_id: nil) @status = status @headers = headers @body = body problem = body.is_a?(Hash) ? body : nil @type = string_field(problem, :type) @title = string_field(problem, :title) @detail = string_field(problem, :detail) @instance = string_field(problem, :instance) super(self.class.(status, body, request_id), code: string_field(problem, :code), request_id: request_id) end |
Instance Attribute Details
#body ⇒ Hash, ... (readonly)
Returns parsed Problem Details, raw body text, or nil.
59 60 61 |
# File 'lib/dinie/runtime/errors.rb', line 59 def body @body end |
#detail ⇒ String? (readonly)
Returns Problem Details ‘detail`.
65 66 67 |
# File 'lib/dinie/runtime/errors.rb', line 65 def detail @detail end |
#headers ⇒ Hash (readonly)
Returns raw response headers.
57 58 59 |
# File 'lib/dinie/runtime/errors.rb', line 57 def headers @headers end |
#instance ⇒ String? (readonly)
Returns Problem Details ‘instance`.
67 68 69 |
# File 'lib/dinie/runtime/errors.rb', line 67 def instance @instance end |
#status ⇒ Integer (readonly)
Returns HTTP status code.
55 56 57 |
# File 'lib/dinie/runtime/errors.rb', line 55 def status @status end |
#title ⇒ String? (readonly)
Returns Problem Details ‘title`.
63 64 65 |
# File 'lib/dinie/runtime/errors.rb', line 63 def title @title end |
#type ⇒ String? (readonly)
Returns Problem Details ‘type` URL.
61 62 63 |
# File 'lib/dinie/runtime/errors.rb', line 61 def type @type end |
Class Method Details
.build_message(status, body, request_id) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
88 89 90 91 92 |
# File 'lib/dinie/runtime/errors.rb', line 88 def self.(status, body, request_id) summary = (body) suffix = request_id.nil? ? "" : " (request_id: #{request_id})" summary ? "#{status} #{summary}#{suffix}" : "#{status} status code (no body)#{suffix}" end |