strict.js 667 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*!
  2. * Module dependencies.
  3. */
  4. 'use strict';
  5. const MongooseError = require('./mongooseError');
  6. /**
  7. * Strict mode error constructor
  8. *
  9. * @param {String} path
  10. * @param {String} [msg]
  11. * @param {Boolean} [immutable]
  12. * @inherits MongooseError
  13. * @api private
  14. */
  15. class StrictModeError extends MongooseError {
  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;