Files

43 lines
804 B
JavaScript
Raw Permalink Normal View History

2014-09-14 07:04:16 -04:00
/*!
* Module dependencies.
*/
2015-11-24 22:08:58 -08:00
var MongooseError = require('../error.js');
2014-09-14 07:04:16 -04:00
/**
* Casting Error constructor.
*
* @param {String} type
* @param {String} value
* @inherits MongooseError
* @api private
*/
2015-11-24 22:08:58 -08:00
function CastError(type, value, path, reason) {
2014-09-14 07:04:16 -04:00
MongooseError.call(this, 'Cast to ' + type + ' failed for value "' + value + '" at path "' + path + '"');
2015-11-24 22:08:58 -08:00
if (Error.captureStackTrace) {
Error.captureStackTrace(this);
} else {
this.stack = new Error().stack
}
2014-09-14 07:04:16 -04:00
this.name = 'CastError';
2015-11-24 22:08:58 -08:00
this.kind = type;
2014-09-14 07:04:16 -04:00
this.value = value;
this.path = path;
2015-11-24 22:08:58 -08:00
this.reason = reason;
}
2014-09-14 07:04:16 -04:00
/*!
* Inherits from MongooseError.
*/
2015-11-24 22:08:58 -08:00
CastError.prototype = Object.create(MongooseError.prototype);
CastError.prototype.constructor = MongooseError;
2014-09-14 07:04:16 -04:00
/*!
* exports
*/
module.exports = CastError;