arnaucube
arnaucube/thoughtsPublic Self-hosted repository
thoughts/node_modules/mongoose/lib/error/objectExpected.js
node_modules/mongoose/lib/error/objectExpected.jsRaw
 1/*!
 2 * Module dependencies.
 3 */
 4
 5var MongooseError = require('../error.js');
 6
 7/**
 8 * Strict mode error constructor
 9 *
10 * @param {String} type
11 * @param {String} value
12 * @inherits MongooseError
13 * @api private
14 */
15
16function ObjectExpectedError(path, val) {
17  MongooseError.call(this, 'Tried to set nested object field `' + path +
18    '` to primitive value `' + val + '` and strict mode is set to throw.');
19  if (Error.captureStackTrace) {
20    Error.captureStackTrace(this);
21  } else {
22    this.stack = new Error().stack;
23  }
24  this.name = 'ObjectExpectedError';
25  this.path = path;
26}
27
28/*!
29 * Inherits from MongooseError.
30 */
31
32ObjectExpectedError.prototype = Object.create(MongooseError.prototype);
33ObjectExpectedError.prototype.constructor = MongooseError;
34
35module.exports = ObjectExpectedError;