/node_modules/mongoose/lib/error/index.js

https://bitbucket.org/coleman333/smartsite · JavaScript · 116 lines · 23 code · 25 blank · 68 comment · 2 complexity · f232a83f26e6c2348faca71ce6be012d MD5 · raw file

  1. /**
  2. * MongooseError constructor
  3. *
  4. * @param {String} msg Error message
  5. * @inherits Error https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error
  6. */
  7. function MongooseError(msg) {
  8. Error.call(this);
  9. if (Error.captureStackTrace) {
  10. Error.captureStackTrace(this);
  11. } else {
  12. this.stack = new Error().stack;
  13. }
  14. this.message = msg;
  15. this.name = 'MongooseError';
  16. }
  17. /*!
  18. * Inherits from Error.
  19. */
  20. MongooseError.prototype = Object.create(Error.prototype);
  21. MongooseError.prototype.constructor = Error;
  22. /*!
  23. * Module exports.
  24. */
  25. module.exports = exports = MongooseError;
  26. /**
  27. * The default built-in validator error messages.
  28. *
  29. * @see Error.messages #error_messages_MongooseError-messages
  30. * @api public
  31. */
  32. MongooseError.messages = require('./messages');
  33. // backward compat
  34. MongooseError.Messages = MongooseError.messages;
  35. /**
  36. * An instance of this error class will be returned when `save()` fails
  37. * because the underlying
  38. * document was not found. The constructor takes one parameter, the
  39. * conditions that mongoose passed to `update()` when trying to update
  40. * the document.
  41. *
  42. * @api public
  43. */
  44. MongooseError.DocumentNotFoundError = require('./notFound');
  45. /**
  46. * An instance of this error class will be returned when mongoose failed to
  47. * cast a value.
  48. *
  49. * @api public
  50. */
  51. MongooseError.CastError = require('./cast');
  52. /**
  53. * An instance of this error class will be returned when [validation](/docs/validation.html) failed.
  54. *
  55. * @api public
  56. */
  57. MongooseError.ValidationError = require('./validation');
  58. /**
  59. * A `ValidationError` has a hash of `errors` that contain individual `ValidatorError` instances
  60. *
  61. * @api public
  62. */
  63. MongooseError.ValidatorError = require('./validator');
  64. /**
  65. * An instance of this error class will be returned when you call `save()` after
  66. * the document in the database was changed in a potentially unsafe way. See
  67. * the [`versionKey` option](/docs/guide.html#versionKey) for more information.
  68. *
  69. * @api public
  70. */
  71. MongooseError.VersionError = require('./version');
  72. /**
  73. * Thrown when a model with the given name was already registered on the connection.
  74. * See [the FAQ about `OverwriteModelError`](/docs/faq.html#overwrite-model-error).
  75. *
  76. * @api public
  77. */
  78. MongooseError.OverwriteModelError = require('./overwriteModel');
  79. /**
  80. * Thrown when you try to access a model that has not been registered yet
  81. *
  82. * @api public
  83. */
  84. MongooseError.MissingSchemaError = require('./missingSchema');
  85. /**
  86. * An instance of this error will be returned if you used an array projection
  87. * and then modified the array in an unsafe way.
  88. *
  89. * @api public
  90. */
  91. MongooseError.DivergentArrayError = require('./divergentArray');