index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. 'use strict';
  2. const MongooseError = require('./mongooseError');
  3. /*!
  4. * Module exports.
  5. */
  6. module.exports = exports = MongooseError;
  7. /**
  8. * The default built-in validator error messages.
  9. *
  10. * @see Error.messages #error_messages_MongooseError-messages
  11. * @api public
  12. */
  13. MongooseError.messages = require('./messages');
  14. // backward compat
  15. MongooseError.Messages = MongooseError.messages;
  16. /**
  17. * An instance of this error class will be returned when `save()` fails
  18. * because the underlying
  19. * document was not found. The constructor takes one parameter, the
  20. * conditions that mongoose passed to `update()` when trying to update
  21. * the document.
  22. *
  23. * @api public
  24. */
  25. MongooseError.DocumentNotFoundError = require('./notFound');
  26. /**
  27. * An instance of this error class will be returned when mongoose failed to
  28. * cast a value.
  29. *
  30. * @api public
  31. */
  32. MongooseError.CastError = require('./cast');
  33. /**
  34. * An instance of this error class will be returned when [validation](/docs/validation.html) failed.
  35. * The `errors` property contains an object whose keys are the paths that failed and whose values are
  36. * instances of CastError or ValidationError.
  37. *
  38. * @api public
  39. */
  40. MongooseError.ValidationError = require('./validation');
  41. /**
  42. * A `ValidationError` has a hash of `errors` that contain individual `ValidatorError` instances
  43. *
  44. * @api public
  45. */
  46. MongooseError.ValidatorError = require('./validator');
  47. /**
  48. * An instance of this error class will be returned when you call `save()` after
  49. * the document in the database was changed in a potentially unsafe way. See
  50. * the [`versionKey` option](/docs/guide.html#versionKey) for more information.
  51. *
  52. * @api public
  53. */
  54. MongooseError.VersionError = require('./version');
  55. /**
  56. * An instance of this error class will be returned when you call `save()` multiple
  57. * times on the same document in parallel. See the [FAQ](/docs/faq.html) for more
  58. * information.
  59. *
  60. * @api public
  61. */
  62. MongooseError.ParallelSaveError = require('./parallelSave');
  63. /**
  64. * Thrown when a model with the given name was already registered on the connection.
  65. * See [the FAQ about `OverwriteModelError`](/docs/faq.html#overwrite-model-error).
  66. *
  67. * @api public
  68. */
  69. MongooseError.OverwriteModelError = require('./overwriteModel');
  70. /**
  71. * Thrown when you try to access a model that has not been registered yet
  72. *
  73. * @api public
  74. */
  75. MongooseError.MissingSchemaError = require('./missingSchema');
  76. /**
  77. * An instance of this error will be returned if you used an array projection
  78. * and then modified the array in an unsafe way.
  79. *
  80. * @api public
  81. */
  82. MongooseError.DivergentArrayError = require('./divergentArray');