Exception: Shaf::Errors::ValidationError

Inherits:
ServerError show all
Defined in:
lib/shaf/errors.rb

Instance Attribute Summary collapse

Attributes inherited from ServerError

#code, #title

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, fields) ⇒ ValidationError

Returns a new instance of ValidationError.



125
126
127
128
129
# File 'lib/shaf/errors.rb', line 125

def initialize(msg, fields)
  msg ||= "The entity being created/updated is invalid"
  super(msg, code: "VALIDATION_ERROR", title: "Invalid entity")
  @fields = fields || {}
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



113
114
115
# File 'lib/shaf/errors.rb', line 113

def fields
  @fields
end

Class Method Details

.from_sequel(validation_failed) ⇒ Object



115
116
117
118
119
# File 'lib/shaf/errors.rb', line 115

def self.from_sequel(validation_failed)
  new(validation_failed.message, validation_failed.errors).tap do |err|
    err.set_backtrace(validation_failed.backtrace)
  end
end

Instance Method Details

#http_statusObject



121
122
123
# File 'lib/shaf/errors.rb', line 121

def http_status
  422
end