You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
2.6 KiB
117 lines
2.6 KiB
|
|
/**
|
|
* MongooseError constructor
|
|
*
|
|
* @param {String} msg Error message
|
|
* @inherits Error https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error
|
|
*/
|
|
|
|
function MongooseError(msg) {
|
|
Error.call(this);
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(this);
|
|
} else {
|
|
this.stack = new Error().stack;
|
|
}
|
|
this.message = msg;
|
|
this.name = 'MongooseError';
|
|
}
|
|
|
|
/*!
|
|
* Inherits from Error.
|
|
*/
|
|
|
|
MongooseError.prototype = Object.create(Error.prototype);
|
|
MongooseError.prototype.constructor = Error;
|
|
|
|
/*!
|
|
* Module exports.
|
|
*/
|
|
|
|
module.exports = exports = MongooseError;
|
|
|
|
/**
|
|
* The default built-in validator error messages.
|
|
*
|
|
* @see Error.messages #error_messages_MongooseError-messages
|
|
* @api public
|
|
*/
|
|
|
|
MongooseError.messages = require('./messages');
|
|
|
|
// backward compat
|
|
MongooseError.Messages = MongooseError.messages;
|
|
|
|
/**
|
|
* An instance of this error class will be returned when `save()` fails
|
|
* because the underlying
|
|
* document was not found. The constructor takes one parameter, the
|
|
* conditions that mongoose passed to `update()` when trying to update
|
|
* the document.
|
|
*
|
|
* @api public
|
|
*/
|
|
|
|
MongooseError.DocumentNotFoundError = require('./notFound');
|
|
|
|
/**
|
|
* An instance of this error class will be returned when mongoose failed to
|
|
* cast a value.
|
|
*
|
|
* @api public
|
|
*/
|
|
|
|
MongooseError.CastError = require('./cast');
|
|
|
|
/**
|
|
* An instance of this error class will be returned when [validation](/docs/validation.html) failed.
|
|
*
|
|
* @api public
|
|
*/
|
|
|
|
MongooseError.ValidationError = require('./validation');
|
|
|
|
/**
|
|
* A `ValidationError` has a hash of `errors` that contain individual `ValidatorError` instances
|
|
*
|
|
* @api public
|
|
*/
|
|
|
|
MongooseError.ValidatorError = require('./validator');
|
|
|
|
/**
|
|
* An instance of this error class will be returned when you call `save()` after
|
|
* the document in the database was changed in a potentially unsafe way. See
|
|
* the [`versionKey` option](/docs/guide.html#versionKey) for more information.
|
|
*
|
|
* @api public
|
|
*/
|
|
|
|
MongooseError.VersionError = require('./version');
|
|
|
|
/**
|
|
* Thrown when a model with the given name was already registered on the connection.
|
|
* See [the FAQ about `OverwriteModelError`](/docs/faq.html#overwrite-model-error).
|
|
*
|
|
* @api public
|
|
*/
|
|
|
|
MongooseError.OverwriteModelError = require('./overwriteModel');
|
|
|
|
/**
|
|
* Thrown when you try to access a model that has not been registered yet
|
|
*
|
|
* @api public
|
|
*/
|
|
|
|
MongooseError.MissingSchemaError = require('./missingSchema');
|
|
|
|
/**
|
|
* An instance of this error will be returned if you used an array projection
|
|
* and then modified the array in an unsafe way.
|
|
*
|
|
* @api public
|
|
*/
|
|
|
|
MongooseError.DivergentArrayError = require('./divergentArray');
|