Exception: Arca::ResponseError

Inherits:
Error
  • Object
show all
Defined in:
lib/arca/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)


7
8
9
10
11
12
# File 'lib/arca/errors/response_error.rb', line 7

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.



5
6
7
# File 'lib/arca/errors/response_error.rb', line 5

def errors
  @errors
end

Instance Method Details

#code?(code) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/arca/errors/response_error.rb', line 14

def code?(code)
  @errors.any? { |e| e[:code].to_s == code.to_s }
end