Class: Hanami::Settings::InvalidSettingsError

Inherits:
Error
  • Object
show all
Defined in:
lib/hanami/settings.rb

Overview

Error raised when setting values do not meet their type expectations.

Its message collects all the individual errors that can be raised for each setting.

Since:

  • 2.0.0

Instance Method Summary collapse

Constructor Details

#initialize(errors) ⇒ InvalidSettingsError

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of InvalidSettingsError.

Since:

  • 2.0.0



67
68
69
70
# File 'lib/hanami/settings.rb', line 67

def initialize(errors)
  super()
  @errors = errors
end

Instance Method Details

#to_sString

Returns the exception’s message.

Returns:

  • (String)

Since:

  • 2.0.0



78
79
80
81
82
83
84
# File 'lib/hanami/settings.rb', line 78

def to_s
  <<~STR.strip
    Could not initialize settings. The following settings were invalid:

    #{@errors.map { |setting, message| "#{setting}: #{message}" }.join("\n")}
  STR
end