Exception: Giftrocket::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/giftrocket/error.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Error

Returns a new instance of Error.



4
5
6
7
# File 'lib/giftrocket/error.rb', line 4

def initialize(response)
  @response = response
  super
end

Instance Method Details

#messageObject



9
10
11
12
13
# File 'lib/giftrocket/error.rb', line 9

def message
  response_json = JSON.parse(@response.body).with_indifferent_access
  errors = response_json[:errors]
  "Code: #{@response.code}; Data: #{errors}"
end