Exception: Sequel::ValidationFailed

Inherits:
Error show all
Defined in:
lib/sequel/model/exceptions.rb

Overview

Exception class raised when raise_on_save_failure is set and validation fails

Constant Summary

Constants inherited from Error

Error::AdapterNotFound, Error::InvalidOperation, Error::InvalidValue, Error::PoolTimeoutError, Error::Rollback

Instance Attribute Summary collapse

Attributes inherited from Error

#wrapped_exception

Instance Method Summary collapse

Constructor Details

#initialize(errors) ⇒ ValidationFailed

Returns a new instance of ValidationFailed.



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/sequel/model/exceptions.rb', line 36

def initialize(errors)
  if errors.is_a?(Sequel::Model)
    @model = errors
    errors = @model.errors
  end

  if errors.respond_to?(:full_messages)
    @errors = errors
    super(errors.full_messages.join(', '))
  else
    super
  end
end

Instance Attribute Details

#errorsObject (readonly)

The Sequel::Model::Errors object related to this exception.



34
35
36
# File 'lib/sequel/model/exceptions.rb', line 34

def errors
  @errors
end

#modelObject (readonly)

The Sequel::Model object related to this exception.



31
32
33
# File 'lib/sequel/model/exceptions.rb', line 31

def model
  @model
end