error.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. this.stack = new Error().stack;
  10. this.message = msg;
  11. this.name = 'MongooseError';
  12. };
  13. /*!
  14. * Inherits from Error.
  15. */
  16. MongooseError.prototype = Object.create(Error.prototype);
  17. MongooseError.prototype.constructor = Error;
  18. /*!
  19. * Module exports.
  20. */
  21. module.exports = exports = MongooseError;
  22. /**
  23. * The default built-in validator error messages.
  24. *
  25. * @see Error.messages #error_messages_MongooseError-messages
  26. * @api public
  27. */
  28. MongooseError.messages = require('./error/messages');
  29. // backward compat
  30. MongooseError.Messages = MongooseError.messages;
  31. /*!
  32. * Expose subclasses
  33. */
  34. MongooseError.CastError = require('./error/cast');
  35. MongooseError.ValidationError = require('./error/validation')
  36. MongooseError.ValidatorError = require('./error/validator')
  37. MongooseError.VersionError =require('./error/version')
  38. MongooseError.OverwriteModelError = require('./error/overwriteModel')
  39. MongooseError.MissingSchemaError = require('./error/missingSchema')
  40. MongooseError.DivergentArrayError = require('./error/divergentArray')