Exception: LabelZoom::APIError

Inherits:
Error
  • Object
show all
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.

Instance Attribute Summary collapse

Instance Method Summary collapse

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(message, status:, request_id: nil, raw_body: "")
  super(message)
  @status = status
  @request_id = request_id
  @raw_body = raw_body
end

Instance Attribute Details

#raw_bodyString (readonly)

Returns the raw response body, untruncated. #message is derived from it and capped at 512 characters; this is not.

Returns:

  • (String)

    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_idString? (readonly)

Returns the X-LZ-Request-Id response header, if present. Quote this to LabelZoom support -- it identifies the exact request server-side.

Returns:

  • (String, nil)

    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

#statusInteger (readonly)

Returns the HTTP status code the API returned.

Returns:

  • (Integer)

    the HTTP status code the API returned.



13
14
15
# File 'lib/labelzoom/errors.rb', line 13

def status
  @status
end