version.js 775 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. /*!
  3. * Module dependencies.
  4. */
  5. const MongooseError = require('./mongooseError');
  6. /**
  7. * Version Error constructor.
  8. *
  9. * @param {Document} doc
  10. * @param {Number} currentVersion
  11. * @param {Array<String>} modifiedPaths
  12. * @api private
  13. */
  14. class VersionError extends MongooseError {
  15. constructor(doc, currentVersion, modifiedPaths) {
  16. const modifiedPathsStr = modifiedPaths.join(', ');
  17. super('No matching document found for id "' + doc._doc._id +
  18. '" version ' + currentVersion + ' modifiedPaths "' + modifiedPathsStr + '"');
  19. this.version = currentVersion;
  20. this.modifiedPaths = modifiedPaths;
  21. }
  22. }
  23. Object.defineProperty(VersionError.prototype, 'name', {
  24. value: 'VersionError'
  25. });
  26. /*!
  27. * exports
  28. */
  29. module.exports = VersionError;