Exception: MuchRails::InvalidError
- Inherits:
-
StandardError
- Object
- StandardError
- MuchRails::InvalidError
- Defined in:
- lib/much-rails/invalid_error.rb
Overview
MuchRails::InvalidError allows for raising and auto-rescueing general validation errors outside the scope of e.g. an ActiveRecord save.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #error_messages ⇒ Object
-
#initialize(backtrace: nil, **errors) ⇒ InvalidError
constructor
A new instance of InvalidError.
Constructor Details
#initialize(backtrace: nil, **errors) ⇒ InvalidError
Returns a new instance of InvalidError.
10 11 12 13 14 15 |
# File 'lib/much-rails/invalid_error.rb', line 10 def initialize(backtrace: nil, **errors) @errors = errors super(@errors.inspect) set_backtrace(backtrace) if backtrace end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/much-rails/invalid_error.rb', line 8 def errors @errors end |
Instance Method Details
#error_messages ⇒ Object
17 18 19 20 21 |
# File 'lib/much-rails/invalid_error.rb', line 17 def @errors.to_a.map do |(field_name, )| "#{field_name}: #{Array.wrap().to_sentence}" end end |