Exception: Crm::Errors::InvalidValues

Inherits:
ClientError show all
Defined in:
lib/crm/errors.rb

Overview

InvalidValues is raised if the keys of a create or update request are recognized but include incorrect values.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, validation_errors = {}) ⇒ InvalidValues

Returns a new instance of InvalidValues.



140
141
142
143
144
# File 'lib/crm/errors.rb', line 140

def initialize(message = nil, validation_errors = {})
  super("#{message} #{validation_errors.map{ |h| h['message'] }.to_sentence}.")

  @validation_errors = validation_errors
end

Instance Attribute Details

#validation_errorsArray<Hash{String => String}> (readonly)

Returns the list of validation errors. The items in the list are hashes consisting of a code (the name of the validation error, i.e. one of the rails validation error codes), an attribute name and an English translation (message). You may use code to translate the message into other languages.

Examples:

[
  {
    "code" => "blank",
    "attribute" => "name",
    "message" => "name is blank",
  },
]

Returns:

  • (Array<Hash{String => String}>)


138
139
140
# File 'lib/crm/errors.rb', line 138

def validation_errors
  @validation_errors
end