Exception: CircleSo::APIError

Inherits:
Error
  • Object
show all
Defined in:
lib/circle_so/errors.rb

Overview

Raised for any non-2xx response from the Circle API. Carries the HTTP status, the parsed response body (Hash when JSON, String otherwise), and a classification kind mirroring the status:

:unauthorized  401 — wrong/invalid token (or a v1 token on the v2 API)
:forbidden     403 — plan no longer allows the endpoint
:not_found     404 with a JSON body — missing record/param
:wrong_path    404 with an HTML body — the route does not exist
:rate_limited  429
:server_error  5xx
:unknown       anything else

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status:, body: nil, kind: :unknown) ⇒ APIError

Returns a new instance of APIError.



20
21
22
23
24
25
# File 'lib/circle_so/errors.rb', line 20

def initialize(message, status:, body: nil, kind: :unknown)
  super(message)
  @status = status
  @body = body
  @kind = kind
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



18
19
20
# File 'lib/circle_so/errors.rb', line 18

def body
  @body
end

#kindObject (readonly)

Returns the value of attribute kind.



18
19
20
# File 'lib/circle_so/errors.rb', line 18

def kind
  @kind
end

#statusObject (readonly)

Returns the value of attribute status.



18
19
20
# File 'lib/circle_so/errors.rb', line 18

def status
  @status
end