Exception: Afipws::ResponseError

Inherits:
Error
  • Object
show all
Defined in:
lib/afipws/errors/response_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Error

#retriable?

Constructor Details

#initialize(errors) ⇒ ResponseError

Returns a new instance of ResponseError.

Raises:

  • (ArgumentError)


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

#errorsObject (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

Returns:

  • (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