Exception: LabelZoom::APIError
- Defined in:
- lib/labelzoom/errors.rb
Overview
Base class for every error the LabelZoom API returns.
Rescue this to handle them all. Note that ValidationError deliberately does not descend from it.
Direct Known Subclasses
BadRequestError, ForbiddenError, NotFoundError, PayloadTooLargeError, RateLimitedError, ServerError, UnauthorizedError
Instance Attribute Summary collapse
-
#raw_body ⇒ String
readonly
The raw response body, untruncated.
-
#request_id ⇒ String?
readonly
The X-LZ-Request-Id response header, if present.
-
#status ⇒ Integer
readonly
The HTTP status code the API returned.
Instance Method Summary collapse
-
#initialize(message, status:, request_id: nil, raw_body: "") ⇒ APIError
constructor
A new instance of APIError.
Constructor Details
#initialize(message, status:, request_id: nil, raw_body: "") ⇒ APIError
Returns a new instance of APIError.
23 24 25 26 27 28 |
# File 'lib/labelzoom/errors.rb', line 23 def initialize(, status:, request_id: nil, raw_body: "") super() @status = status @request_id = request_id @raw_body = raw_body end |
Instance Attribute Details
#raw_body ⇒ String (readonly)
Returns the raw response body, untruncated. #message is derived from it and capped at 512 characters; this is not.
21 22 23 |
# File 'lib/labelzoom/errors.rb', line 21 def raw_body @raw_body end |
#request_id ⇒ String? (readonly)
Returns the X-LZ-Request-Id response header, if present. Quote this to LabelZoom support -- it identifies the exact request server-side.
17 18 19 |
# File 'lib/labelzoom/errors.rb', line 17 def request_id @request_id end |
#status ⇒ Integer (readonly)
Returns the HTTP status code the API returned.
13 14 15 |
# File 'lib/labelzoom/errors.rb', line 13 def status @status end |