arnaucube
arnaucube/thoughtsPublic Self-hosted repository
thoughts/node_modules/mongoose/lib/error/cast.js
node_modules/mongoose/lib/error/cast.jsRaw
 1/*!
 2 * Module dependencies.
 3 */
 4
 5var MongooseError = require('../error.js');
 6
 7/**
 8 * Casting Error constructor.
 9 *
10 * @param {String} type
11 * @param {String} value
12 * @inherits MongooseError
13 * @api private
14 */
15
16function CastError(type, value, path, reason) {
17  MongooseError.call(this, 'Cast to ' + type + ' failed for value "' + value + '" at path "' + path + '"');
18  if (Error.captureStackTrace) {
19    Error.captureStackTrace(this);
20  } else {
21    this.stack = new Error().stack;
22  }
23  this.name = 'CastError';
24  this.kind = type;
25  this.value = value;
26  this.path = path;
27  this.reason = reason;
28}
29
30/*!
31 * Inherits from MongooseError.
32 */
33
34CastError.prototype = Object.create(MongooseError.prototype);
35CastError.prototype.constructor = MongooseError;
36
37
38/*!
39 * exports
40 */
41
42module.exports = CastError;