1 |
|
2 |
|
3 |
|
4 |
|
5 | 'use strict';
|
6 |
|
7 | const MongooseError = require('./');
|
8 |
|
9 |
|
10 | class ObjectExpectedError extends MongooseError {
|
11 | |
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
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 |
|
26 | Object.defineProperty(ObjectExpectedError.prototype, 'name', {
|
27 | value: 'ObjectExpectedError'
|
28 | });
|
29 |
|
30 | module.exports = ObjectExpectedError;
|