Exception: MyJohnDeereApi::InvalidRecordError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/my_john_deere_api/errors/invalid_record_error.rb

Overview

This error is used in a context that will fail in the absence of a valid oAuth access token. We have classes that may only need access tokens for some use cases.

Instance Method Summary collapse

Constructor Details

#initialize(errors = {}) ⇒ InvalidRecordError

argument is a hash of attributes and their error messages, which will be built into the raised message.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/my_john_deere_api/errors/invalid_record_error.rb', line 13

def initialize(errors = {})
  message = 'Record is invalid'

  unless errors.empty?
    attribute_messages = []

    errors.each do |attribute, message|
      attribute_messages << "#{attribute} #{message}"
    end

    message = "#{message}: #{attribute_messages.join('; ')}"
  end

  super(message)
end