class Roda::RodaPlugins::TypecastParams::Error

what is expected. Should probably be treated as a 4xx error.
Exception class for errors that are due to the submitted parameters not matching

def self.create(keys, reason, e)

instance of the class, create a new instance to wrap it.
Set the keys in the given exception. If the exception is not already an
def self.create(keys, reason, e)
  if e.is_a?(self)
    e.keys ||= keys
    e.reason ||= reason
    e
  else
    backtrace = e.backtrace
    e = new("#{e.class}: #{e.message}")
    e.keys = keys
    e.reason = reason
    e.set_backtrace(backtrace) if backtrace
    e
  end
end

def all_errors

def all_errors
  @all_errors ||= [self]
end

def param_name

param_name => 'album[artist][name]'
# keys: ['album', 'artist', 'name']

param_name => 'artist[name]'
# keys: ['artist', 'name']

param_name => 'page'
# keys: ['page']

Example:

used directly.
parameters. # If the parameters were submitted via JSON, #keys should be
and assumes the typical rack parsing of these content types into
application/x-www-form-urlencoded or multipart/form-data content types,
designed for cases where the parameter was submitted with the typical
The likely parameter name where the contents were not expected. This is
def param_name
  if keys.length > 1
    first, *rest = keys
    v = first.dup
    rest.each do |param|
      v << "["
      v << param unless param.is_a?(Integer)
      v << "]"
    end
    v
  else
    keys.first
  end
end

def param_names

related to all captured exceptions.
captured inside the convert! block, this will contain the parameter names
#param_name. If Params#convert! was used and multiple exceptions were
expected. If Params#convert! was not used, this will be an array containing
An array of all parameter names for parameters where the context were not
def param_names
  all_errors.map(&:param_name)
end