Sha256: 417f14720b8138c2d43e2c4126049ae84054faedfd3db5a2fb98466cb0ea008a

Contents?: true

Size: 1.33 KB

Versions: 13

Compression:

Stored size: 1.33 KB

Contents

module Sequel
  # Exception class raised when +raise_on_save_failure+ is set and a before hook returns false
  # or an around hook doesn't call super or yield.
  class HookFailed < Error
    # The Sequel::Model instance related to this error.
    attr_reader :model

    def initialize(message, model=nil)
      @model = model
      super(message)
    end
  end

  # Deprecated alias for HookFailed, kept for backwards compatibility
  BeforeHookFailed = HookFailed
  
  # Exception class raised when +require_modification+ is set and an UPDATE or DELETE statement to modify the dataset doesn't
  # modify a single row.
  class NoExistingObject < Error; end
  
  # Raised when an undefined association is used when eager loading.
  class UndefinedAssociation < Error; end
  
  # 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)
      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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
sequel-4.1.1 lib/sequel/model/exceptions.rb
sequel-4.1.0 lib/sequel/model/exceptions.rb
sequel-4.0.0 lib/sequel/model/exceptions.rb
sequel-3.48.0 lib/sequel/model/exceptions.rb
sequel-3.47.0 lib/sequel/model/exceptions.rb
sequel-3.46.0 lib/sequel/model/exceptions.rb
sequel-3.45.0 lib/sequel/model/exceptions.rb
sequel-3.44.0 lib/sequel/model/exceptions.rb
sequel-3.43.0 lib/sequel/model/exceptions.rb
sequel-3.42.0 lib/sequel/model/exceptions.rb
sequel-3.41.0 lib/sequel/model/exceptions.rb
sequel-3.40.0 lib/sequel/model/exceptions.rb
sequel-3.39.0 lib/sequel/model/exceptions.rb