Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

notFound.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 'use strict';
  2. /*!
  3. * Module dependencies.
  4. */
  5. const MongooseError = require('./');
  6. const util = require('util');
  7. /*!
  8. * OverwriteModel Error constructor.
  9. *
  10. * @inherits MongooseError
  11. */
  12. function DocumentNotFoundError(filter, model, numAffected, result) {
  13. let msg;
  14. const messages = MongooseError.messages;
  15. if (messages.DocumentNotFoundError != null) {
  16. msg = typeof messages.DocumentNotFoundError === 'function' ?
  17. messages.DocumentNotFoundError(filter, model) :
  18. messages.DocumentNotFoundError;
  19. } else {
  20. msg = 'No document found for query "' + util.inspect(filter) +
  21. '" on model "' + model + '"';
  22. }
  23. MongooseError.call(this, msg);
  24. this.name = 'DocumentNotFoundError';
  25. this.result = result;
  26. this.numAffected = numAffected;
  27. if (Error.captureStackTrace) {
  28. Error.captureStackTrace(this);
  29. } else {
  30. this.stack = new Error().stack;
  31. }
  32. this.filter = filter;
  33. // Backwards compat
  34. this.query = filter;
  35. }
  36. /*!
  37. * Inherits from MongooseError.
  38. */
  39. DocumentNotFoundError.prototype = Object.create(MongooseError.prototype);
  40. DocumentNotFoundError.prototype.constructor = MongooseError;
  41. /*!
  42. * exports
  43. */
  44. module.exports = DocumentNotFoundError;