Exception: Common::Exceptions::ValidationErrors
- Defined in:
- lib/common/exceptions/validation_errors.rb
Overview
Validation Error - an ActiveModel having validation errors, can be sent to this exception
Direct Known Subclasses
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(resource) ⇒ ValidationErrors
constructor
A new instance of ValidationErrors.
Methods inherited from BaseError
#log_to_sentry?, #message, #sentry_type, #status_code
Constructor Details
#initialize(resource) ⇒ ValidationErrors
Returns a new instance of ValidationErrors.
12 13 14 15 |
# File 'lib/common/exceptions/validation_errors.rb', line 12 def initialize(resource) @resource = resource raise TypeError, 'the resource provided has no errors' if resource.errors.empty? end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
10 11 12 |
# File 'lib/common/exceptions/validation_errors.rb', line 10 def resource @resource end |
Instance Method Details
#errors ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/common/exceptions/validation_errors.rb', line 17 def errors @resource.errors.map do |error| = error. attributes = error_attributes(error.attribute, error., ) SerializableError.new(attributes) end end |