UNPKG

670 BJavaScriptView Raw
1/*!
2 * Module dependencies.
3 */
4
5'use strict';
6
7const MongooseError = require('./');
8
9
10class ObjectExpectedError extends MongooseError {
11 /**
12 * Strict mode error constructor
13 *
14 * @param {string} type
15 * @param {string} value
16 * @api private
17 */
18 constructor(path, val) {
19 const typeDescription = Array.isArray(val) ? 'array' : 'primitive value';
20 super('Tried to set nested object field `' + path +
21 `\` to ${typeDescription} \`` + val + '` and strict mode is set to throw.');
22 this.path = path;
23 }
24}
25
26Object.defineProperty(ObjectExpectedError.prototype, 'name', {
27 value: 'ObjectExpectedError'
28});
29
30module.exports = ObjectExpectedError;