You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
796 B

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