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

Instance Attribute Summary collapse

Attributes inherited from Error

#wrapped_exception

Instance Method Summary collapse

Methods inherited from Error

#cause

Constructor Details

#initialize(errors = nil) ⇒ ValidationFailed

Returns a new instance of ValidationFailed.



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/sequel/model/exceptions.rb', line 53

def initialize(errors=nil)
  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.



51
52
53
# File 'lib/sequel/model/exceptions.rb', line 51

def errors
  @errors
end

#modelObject (readonly)

The Sequel::Model object related to this exception.



48
49
50
# File 'lib/sequel/model/exceptions.rb', line 48

def model
  @model
end