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.

55 lines
1.3 KiB

  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('./error/messages');
  33. // backward compat
  34. MongooseError.Messages = MongooseError.messages;
  35. /*!
  36. * Expose subclasses
  37. */
  38. MongooseError.CastError = require('./error/cast');
  39. MongooseError.ValidationError = require('./error/validation');
  40. MongooseError.ValidatorError = require('./error/validator');
  41. MongooseError.VersionError = require('./error/version');
  42. MongooseError.OverwriteModelError = require('./error/overwriteModel');
  43. MongooseError.MissingSchemaError = require('./error/missingSchema');
  44. MongooseError.DivergentArrayError = require('./error/divergentArray');