Exception: Arca::ResponseError
- Defined in:
- lib/arca/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.
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
#errors ⇒ Object (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
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 |