Exception: SuperPDP::APIError

Inherits:
Error
  • Object
show all
Defined in:
lib/super_pdp/error.rb

Overview

Raised for any non-2xx HTTP response. Carries the status and parsed body.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, body) ⇒ APIError

Returns a new instance of APIError.



10
11
12
13
14
15
# File 'lib/super_pdp/error.rb', line 10

def initialize(status, body)
  @status = status
  @body = body
  message = body.is_a?(Hash) ? (body["message"] || body["error"] || body.to_s) : body.to_s
  super("SuperPDP API error #{status}: #{message}")
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/super_pdp/error.rb', line 8

def body
  @body
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/super_pdp/error.rb', line 8

def status
  @status
end