Exception: Common::Exceptions::SchemaValidationErrors

Inherits:
BaseError
  • Object
show all
Defined in:
lib/common/exceptions/schema_validation_errors.rb

Instance Method Summary collapse

Methods inherited from BaseError

#log_to_sentry?, #message, #sentry_type, #status_code

Constructor Details

#initialize(resource) ⇒ SchemaValidationErrors

Returns a new instance of SchemaValidationErrors.

Raises:

  • (TypeError)


9
10
11
12
# File 'lib/common/exceptions/schema_validation_errors.rb', line 9

def initialize(resource)
  @resource = resource
  raise TypeError, 'the resource provided has no errors' if resource.blank?
end

Instance Method Details

#errorsObject



14
15
16
17
18
19
20
21
22
# File 'lib/common/exceptions/schema_validation_errors.rb', line 14

def errors
  @resource.map do |error|
    SerializableError.new(
      i18n_data.merge(
        detail: error
      )
    )
  end
end