Sha256: 867406fa53cf75b20d4da9079799298b5c848205dad27891f59280f29d32dc2f

Contents?: true

Size: 1.31 KB

Versions: 14

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8
module Mongoid #:nodoc
  module Errors #:nodoc

    # Raised when querying the database for a document by a specific id which
    # does not exist.
    class DocumentNotFound < RuntimeError
      def initialize(klass, identifier)
        @klass, @identifier = klass, identifier
      end
      def message
        "Document not found for class #{@klass} and id #{@identifier}"
      end
    end

    # Raised when invalid options are passed into a constructor or method.
    class InvalidOptions < RuntimeError; end

    # Raised when the database connection has not been set up.
    class InvalidDatabase < RuntimeError; end

    # Raised when a persisence method ending in ! fails validation.
    class Validations < RuntimeError
      def initialize(errors)
        @errors = errors
      end
      def message
        "Validation failed: #{@errors.full_messages}"
      end
    end

    # This error is raised when trying to access a Mongo::Collection from an
    # embedded document.
    class InvalidCollection < RuntimeError
      def initialize(klass)
        @klass = klass
      end
      def message
        "Access to the collection for #{@klass.name} is not allowed " +
          "since it is an embedded document, please access a collection from " +
          "the root document"
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mongoid-1.1.1 lib/mongoid/errors.rb
mongoid-1.1.0 lib/mongoid/errors.rb
mongoid-1.0.6 lib/mongoid/errors.rb
mongoid-1.0.5 lib/mongoid/errors.rb
mongoid-1.0.4 lib/mongoid/errors.rb
mongoid-1.0.3 lib/mongoid/errors.rb
mongoid-1.0.2 lib/mongoid/errors.rb
mongoid-1.0.1 lib/mongoid/errors.rb
mongoid-1.0.0 lib/mongoid/errors.rb
mongoid-0.12.0 lib/mongoid/errors.rb
mongoid-0.11.9 lib/mongoid/errors.rb
mongoid-0.11.8 lib/mongoid/errors.rb
mongoid-0.11.7 lib/mongoid/errors.rb
mongoid-0.11.6 lib/mongoid/errors.rb