notFound.js 993 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use strict';
  2. /*!
  3. * Module dependencies.
  4. */
  5. const MongooseError = require('./');
  6. const util = require('util');
  7. class DocumentNotFoundError extends MongooseError {
  8. /*!
  9. * OverwriteModel Error constructor.
  10. */
  11. constructor(filter, model, numAffected, result) {
  12. let msg;
  13. const messages = MongooseError.messages;
  14. if (messages.DocumentNotFoundError != null) {
  15. msg = typeof messages.DocumentNotFoundError === 'function' ?
  16. messages.DocumentNotFoundError(filter, model) :
  17. messages.DocumentNotFoundError;
  18. } else {
  19. msg = 'No document found for query "' + util.inspect(filter) +
  20. '" on model "' + model + '"';
  21. }
  22. super(msg);
  23. this.result = result;
  24. this.numAffected = numAffected;
  25. this.filter = filter;
  26. // Backwards compat
  27. this.query = filter;
  28. }
  29. }
  30. Object.defineProperty(DocumentNotFoundError.prototype, 'name', {
  31. value: 'DocumentNotFoundError'
  32. });
  33. /*!
  34. * exports
  35. */
  36. module.exports = DocumentNotFoundError;