Exception: Balanced::Error

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

Overview

Custom error class for rescuing from all Balanced errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Error

Returns a new instance of Error.



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

def initialize(response)
  @response = response
  super error_message
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#bodyObject



12
13
14
# File 'lib/balanced_ach/error.rb', line 12

def body
  Utils.hash_with_indifferent_read_access response[:body]
end

#error_messageObject



16
17
18
19
20
21
22
# File 'lib/balanced_ach/error.rb', line 16

def error_message
  set_attrs
  extra = body[:additional] ? " -- #{body[:additional]}" : ""
  "#{self.class.name}(#{response[:status]})::#{body[:status]}:: "\
  "#{response[:method].to_s.upcase} #{response[:url].to_s}: "\
  "#{body[:category_code]}: #{body[:description]} #{extra}"
end