Exception: Ibanity::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Ibanity::Error
- Defined in:
- lib/ibanity/error.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(errors, ibanity_request_id) ⇒ Error
constructor
A new instance of Error.
- #to_s ⇒ Object
Constructor Details
#initialize(errors, ibanity_request_id) ⇒ Error
Returns a new instance of Error.
5 6 7 8 |
# File 'lib/ibanity/error.rb', line 5 def initialize(errors, ibanity_request_id) @errors = errors @ibanity_request_id = ibanity_request_id end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'lib/ibanity/error.rb', line 3 def errors @errors end |
Instance Method Details
#to_s ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ibanity/error.rb', line 10 def to_s if @errors.is_a?(Array) && @errors.size > 0 formatted_errors = @errors.map do |error| if error["meta"] && error["meta"]["attribute"] "* #{error["code"]}: '#{error["meta"]["attribute"]}' #{error["detail"]}" elsif error["meta"] && error["meta"]["resource"] "* #{error["code"]}: '#{error["meta"]["resource"]}' #{error["detail"]}" else "* #{error["code"]}: #{error["detail"]}" end end formatted_errors << "* ibanity_request_id: #{@ibanity_request_id}" formatted_errors.join("\n") elsif @errors.is_a?(Hash) "* #{@errors["error"]}: #{@errors["error_description"]}\n * Error hint: #{@errors["error_hint"]}\n * ibanity_request_id: #{@ibanity_request_id}" elsif @errors.is_a?(String) @errors else super end end |