1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
# frozen-string-literal: true
module Sequel
# Exception class raised when +raise_on_save_failure+ is set and an action is canceled in a hook.
# or an around hook doesn't yield.
class HookFailed < Error
# The Sequel::Model instance related to this error.
attr_reader :model
def initialize(message=nil, model=nil)
@model = model
super(message)
end
end
(
# Exception class raised when +require_modification+ is set and an UPDATE or DELETE statement to modify the dataset doesn't
# modify a single row.
NoExistingObject = Class.new(Error)
).name
(
# Raised when an undefined association is used when eager loading.
UndefinedAssociation = Class.new(Error)
).name
(
# Raised when a mass assignment method is called in strict mode with either a restricted column
# or a column without a setter method.
MassAssignmentRestriction = Class.new(Error)
).name
# Exception class raised when +raise_on_save_failure+ is set and validation fails
class ValidationFailed < Error
# The Sequel::Model object related to this exception.
attr_reader :model
# The Sequel::Model::Errors object related to this exception.
attr_reader :errors
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
end
end
|