strict.js 758 B

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