strict.js 766 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 StrictModeError(path, msg) {
  15. msg = msg || 'Field `' + path + '` is not in schema and strict ' +
  16. 'mode is set to throw.';
  17. MongooseError.call(this, msg);
  18. this.name = 'StrictModeError';
  19. if (Error.captureStackTrace) {
  20. Error.captureStackTrace(this);
  21. } else {
  22. this.stack = new Error().stack;
  23. }
  24. this.path = path;
  25. }
  26. /*!
  27. * Inherits from MongooseError.
  28. */
  29. StrictModeError.prototype = Object.create(MongooseError.prototype);
  30. StrictModeError.prototype.constructor = MongooseError;
  31. module.exports = StrictModeError;