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.

index.js 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. 'use strict';
  2. /**
  3. * MongooseError constructor. MongooseError is the base class for all
  4. * Mongoose-specific errors.
  5. *
  6. * ####Example:
  7. * const Model = mongoose.model('Test', new Schema({ answer: Number }));
  8. * const doc = new Model({ answer: 'not a number' });
  9. * const err = doc.validateSync();
  10. *
  11. * err instanceof mongoose.Error; // true
  12. *
  13. * @constructor Error
  14. * @param {String} msg Error message
  15. * @inherits Error https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error
  16. */
  17. const MongooseError = require('./mongooseError');
  18. /**
  19. * The name of the error. The name uniquely identifies this Mongoose error. The
  20. * possible values are:
  21. *
  22. * - `MongooseError`: general Mongoose error
  23. * - `CastError`: Mongoose could not convert a value to the type defined in the schema path. May be in a `ValidationError` class' `errors` property.
  24. * - `DisconnectedError`: This [connection](connections.html) timed out in trying to reconnect to MongoDB and will not successfully reconnect to MongoDB unless you explicitly reconnect.
  25. * - `DivergentArrayError`: You attempted to `save()` an array that was modified after you loaded it with a `$elemMatch` or similar projection
  26. * - `MissingSchemaError`: You tried to access a model with [`mongoose.model()`](api.html#mongoose_Mongoose-model) that was not defined
  27. * - `DocumentNotFoundError`: The document you tried to [`save()`](api.html#document_Document-save) was not found
  28. * - `ValidatorError`: error from an individual schema path's validator
  29. * - `ValidationError`: error returned from [`validate()`](api.html#document_Document-validate) or [`validateSync()`](api.html#document_Document-validateSync). Contains zero or more `ValidatorError` instances in `.errors` property.
  30. * - `MissingSchemaError`: You called `mongoose.Document()` without a schema
  31. * - `ObjectExpectedError`: Thrown when you set a nested path to a non-object value with [strict mode set](guide.html#strict).
  32. * - `ObjectParameterError`: Thrown when you pass a non-object value to a function which expects an object as a paramter
  33. * - `OverwriteModelError`: Thrown when you call [`mongoose.model()`](api.html#mongoose_Mongoose-model) to re-define a model that was already defined.
  34. * - `ParallelSaveError`: Thrown when you call [`save()`](api.html#model_Model-save) on a document when the same document instance is already saving.
  35. * - `StrictModeError`: Thrown when you set a path that isn't the schema and [strict mode](guide.html#strict) is set to `throw`.
  36. * - `VersionError`: Thrown when the [document is out of sync](guide.html#versionKey)
  37. *
  38. * @api public
  39. * @property {String} name
  40. * @memberOf Error
  41. * @instance
  42. */
  43. /*!
  44. * Module exports.
  45. */
  46. module.exports = exports = MongooseError;
  47. /**
  48. * The default built-in validator error messages.
  49. *
  50. * @see Error.messages #error_messages_MongooseError-messages
  51. * @api public
  52. * @memberOf Error
  53. * @static messages
  54. */
  55. MongooseError.messages = require('./messages');
  56. // backward compat
  57. MongooseError.Messages = MongooseError.messages;
  58. /**
  59. * An instance of this error class will be returned when `save()` fails
  60. * because the underlying
  61. * document was not found. The constructor takes one parameter, the
  62. * conditions that mongoose passed to `update()` when trying to update
  63. * the document.
  64. *
  65. * @api public
  66. * @memberOf Error
  67. * @static DocumentNotFoundError
  68. */
  69. MongooseError.DocumentNotFoundError = require('./notFound');
  70. /**
  71. * An instance of this error class will be returned when mongoose failed to
  72. * cast a value.
  73. *
  74. * @api public
  75. * @memberOf Error
  76. * @static CastError
  77. */
  78. MongooseError.CastError = require('./cast');
  79. /**
  80. * An instance of this error class will be returned when [validation](/docs/validation.html) failed.
  81. * The `errors` property contains an object whose keys are the paths that failed and whose values are
  82. * instances of CastError or ValidationError.
  83. *
  84. * @api public
  85. * @memberOf Error
  86. * @static ValidationError
  87. */
  88. MongooseError.ValidationError = require('./validation');
  89. /**
  90. * A `ValidationError` has a hash of `errors` that contain individual `ValidatorError` instances
  91. *
  92. * @api public
  93. * @memberOf Error
  94. * @static ValidatorError
  95. */
  96. MongooseError.ValidatorError = require('./validator');
  97. /**
  98. * An instance of this error class will be returned when you call `save()` after
  99. * the document in the database was changed in a potentially unsafe way. See
  100. * the [`versionKey` option](/docs/guide.html#versionKey) for more information.
  101. *
  102. * @api public
  103. * @memberOf Error
  104. * @static VersionError
  105. */
  106. MongooseError.VersionError = require('./version');
  107. /**
  108. * An instance of this error class will be returned when you call `save()` multiple
  109. * times on the same document in parallel. See the [FAQ](/docs/faq.html) for more
  110. * information.
  111. *
  112. * @api public
  113. * @memberOf Error
  114. * @static ParallelSaveError
  115. */
  116. MongooseError.ParallelSaveError = require('./parallelSave');
  117. /**
  118. * Thrown when a model with the given name was already registered on the connection.
  119. * See [the FAQ about `OverwriteModelError`](/docs/faq.html#overwrite-model-error).
  120. *
  121. * @api public
  122. * @memberOf Error
  123. * @static OverwriteModelError
  124. */
  125. MongooseError.OverwriteModelError = require('./overwriteModel');
  126. /**
  127. * Thrown when you try to access a model that has not been registered yet
  128. *
  129. * @api public
  130. * @memberOf Error
  131. * @static MissingSchemaError
  132. */
  133. MongooseError.MissingSchemaError = require('./missingSchema');
  134. /**
  135. * An instance of this error will be returned if you used an array projection
  136. * and then modified the array in an unsafe way.
  137. *
  138. * @api public
  139. * @memberOf Error
  140. * @static DivergentArrayError
  141. */
  142. MongooseError.DivergentArrayError = require('./divergentArray');