Exception: Brut::Framework::Errors::MissingParameter

Inherits:
Brut::Framework::Error show all
Defined in:
lib/brut/framework/errors/missing_parameter.rb

Overview

Raised when an expected parameter in e.g. a path or a method invocation is not available. This allows classes to give a better error message than the one provided by standard library exceptions like KeyError

Instance Method Summary collapse

Constructor Details

#initialize(missing_param, params_received:, context:) ⇒ MissingParameter

Create the exception

Parameters:

  • missing_param (String|Symbol)

    the name of the missing parameter.

  • params_received (Array<String|Symbol>)

    the parameters that were received in the context that generated this error

  • context (String)

    Any additional context to understand the error



9
10
11
# File 'lib/brut/framework/errors/missing_parameter.rb', line 9

def initialize(missing_param, params_received:, context:)
  super("Parameter '#{missing_param}' was not available. Received params: #{params_received.empty? ? 'no params' : "'" + params_received.join(', ') + "'"}. #{context}")
end