strict.js 670 B

123456789101112131415161718192021222324252627282930313233
  1. /*!
  2. * Module dependencies.
  3. */
  4. 'use strict';
  5. const MongooseError = require('./');
  6. class StrictModeError extends MongooseError {
  7. /**
  8. * Strict mode error constructor
  9. *
  10. * @param {String} path
  11. * @param {String} [msg]
  12. * @param {Boolean} [immutable]
  13. * @inherits MongooseError
  14. * @api private
  15. */
  16. constructor(path, msg, immutable) {
  17. msg = msg || 'Field `' + path + '` is not in schema and strict ' +
  18. 'mode is set to throw.';
  19. super(msg);
  20. this.isImmutableError = !!immutable;
  21. this.path = path;
  22. }
  23. }
  24. Object.defineProperty(StrictModeError.prototype, 'name', {
  25. value: 'StrictModeError'
  26. });
  27. module.exports = StrictModeError;