minor: fixed exception organization

This commit is contained in:
Kyle Banker 2010-01-11 11:38:35 -05:00
parent 3a6865e172
commit 3762e52ac2
3 changed files with 66 additions and 47 deletions

View File

@ -826,7 +826,7 @@ void Init_cbson() {
Code = rb_const_get(mongo, rb_intern("Code"));
rb_require("mongo/types/regexp_of_holding");
RegexpOfHolding = rb_const_get(mongo, rb_intern("RegexpOfHolding"));
rb_require("mongo/errors");
rb_require("mongo/exceptions");
InvalidName = rb_const_get(mongo, rb_intern("InvalidName"));
InvalidStringEncoding = rb_const_get(mongo, rb_intern("InvalidStringEncoding"));
InvalidDocument = rb_const_get(mongo, rb_intern("InvalidDocument"));

View File

@ -38,48 +38,6 @@ module Mongo
OP_QUERY_NO_CURSOR_TIMEOUT = 16
end
# Generic Mongo Ruby Driver exception class.
class MongoRubyError < StandardError; end
# Raised when MongoDB itself has returned an error.
class MongoDBError < RuntimeError; end
# Raised when configuration options cause connections, queries, etc., to fail.
class ConfigurationError < MongoRubyError; end
# Raised when invalid arguments are sent to Mongo Ruby methods.
class MongoArgumentError < MongoRubyError; end
# Raised when given a string is not valid utf-8 (Ruby 1.8 only).
class InvalidStringEncoding < MongoRubyError; end
# Raised when attempting to initialize an invalid ObjectID.
class InvalidObjectID < MongoRubyError; end
# Raised on failures in connection to the database server.
class ConnectionError < MongoRubyError; end
# Raised on failures in connection to the database server.
class ConnectionTimeoutError < MongoRubyError; end
# Raised when trying to insert a document that exceeds the 4MB limit or
# when the document contains objects that can't be serialized as BSON.
class InvalidDocument < MongoDBError; end
# Raised when a database operation fails.
class OperationFailure < MongoDBError; end
# Raised when a connection operation fails.
class ConnectionFailure < MongoDBError; end
# Raised when a client attempts to perform an invalid operation.
class InvalidOperation < MongoDBError; end
# Raised when an invalid name is used.
class InvalidName < RuntimeError; end
# Raised when the client supplies an invalid value to sort by.
class InvalidSortValueError < MongoRubyError; end
end
require 'mongo/types/binary'
@ -93,9 +51,10 @@ require 'mongo/util/conversions'
require 'mongo/util/server_version'
require 'mongo/util/bson_ruby'
require 'mongo/connection'
require 'mongo/db'
require 'mongo/cursor'
require 'mongo/collection'
require 'mongo/admin'
require 'mongo/collection'
require 'mongo/connection'
require 'mongo/cursor'
require 'mongo/db'
require 'mongo/exceptions'
require 'mongo/gridfs'

60
lib/mongo/exceptions.rb Normal file
View File

@ -0,0 +1,60 @@
# --
# Copyright (C) 2008-2009 10gen Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ++
module Mongo
# Generic Mongo Ruby Driver exception class.
class MongoRubyError < StandardError; end
# Raised when MongoDB itself has returned an error.
class MongoDBError < RuntimeError; end
# Raised when configuration options cause connections, queries, etc., to fail.
class ConfigurationError < MongoRubyError; end
# Raised when invalid arguments are sent to Mongo Ruby methods.
class MongoArgumentError < MongoRubyError; end
# Raised when given a string is not valid utf-8 (Ruby 1.8 only).
class InvalidStringEncoding < MongoRubyError; end
# Raised when attempting to initialize an invalid ObjectID.
class InvalidObjectID < MongoRubyError; end
# Raised on failures in connection to the database server.
class ConnectionError < MongoRubyError; end
# Raised on failures in connection to the database server.
class ConnectionTimeoutError < MongoRubyError; end
# Raised when trying to insert a document that exceeds the 4MB limit or
# when the document contains objects that can't be serialized as BSON.
class InvalidDocument < MongoDBError; end
# Raised when a database operation fails.
class OperationFailure < MongoDBError; end
# Raised when a connection operation fails.
class ConnectionFailure < MongoDBError; end
# Raised when a client attempts to perform an invalid operation.
class InvalidOperation < MongoDBError; end
# Raised when an invalid name is used.
class InvalidName < RuntimeError; end
# Raised when the client supplies an invalid value to sort by.
class InvalidSortValueError < MongoRubyError; end
end