Exception: Balanced::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Balanced::Error
- Defined in:
- lib/balanced/error.rb
Overview
Custom error class for rescuing from all API response-related Balanced errors
Direct Known Subclasses
BadGateway, BadRequest, Conflict, Forbidden, FundingInstrumentVerificationError, GatewayTimeout, Gone, InternalServerError, MethodNotAllowed, MoreInformationRequired, NotFound, NotImplemented, PaymentRequired, ServiceUnavailable, StandardError, Unauthorized
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #body ⇒ Hash
- #error_message ⇒ Object
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
8 9 10 11 |
# File 'lib/balanced/error.rb', line 8 def initialize(response) @response = response super end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/balanced/error.rb', line 5 def response @response end |
Instance Method Details
#body ⇒ Hash
14 15 16 17 18 19 |
# File 'lib/balanced/error.rb', line 14 def body @body ||= begin return {} unless response[:body] Utils.hash_with_indifferent_read_access(response[:body]) end end |
#error_message ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/balanced/error.rb', line 21 def 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 |