Exception: Afipws::ResponseError
- Defined in:
- lib/afipws/errors/response_error.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #code?(code) ⇒ Boolean
-
#initialize(errors) ⇒ ResponseError
constructor
A new instance of ResponseError.
Methods inherited from Error
Constructor Details
#initialize(errors) ⇒ ResponseError
Returns a new instance of ResponseError.
5 6 7 8 9 10 |
# File 'lib/afipws/errors/response_error.rb', line 5 def initialize errors raise ArgumentError, '`errors` must be an array of maps, each with :code and :msg keys' unless errors.is_a? Array super errors.map { |e| "#{e[:code]}: #{e[:msg]}" }.join '; ' @errors = errors end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'lib/afipws/errors/response_error.rb', line 3 def errors @errors end |
Instance Method Details
#code?(code) ⇒ Boolean
12 13 14 |
# File 'lib/afipws/errors/response_error.rb', line 12 def code? code @errors.any? { |e| e[:code].to_s == code.to_s } end |