objectExpected.js 804 B

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