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.

42 lines
805 B

  1. /*!
  2. * Module dependencies.
  3. */
  4. var MongooseError = require('../error.js');
  5. /**
  6. * Casting Error constructor.
  7. *
  8. * @param {String} type
  9. * @param {String} value
  10. * @inherits MongooseError
  11. * @api private
  12. */
  13. function CastError(type, value, path, reason) {
  14. MongooseError.call(this, 'Cast to ' + type + ' failed for value "' + value + '" at path "' + path + '"');
  15. if (Error.captureStackTrace) {
  16. Error.captureStackTrace(this);
  17. } else {
  18. this.stack = new Error().stack;
  19. }
  20. this.name = 'CastError';
  21. this.kind = type;
  22. this.value = value;
  23. this.path = path;
  24. this.reason = reason;
  25. }
  26. /*!
  27. * Inherits from MongooseError.
  28. */
  29. CastError.prototype = Object.create(MongooseError.prototype);
  30. CastError.prototype.constructor = MongooseError;
  31. /*!
  32. * exports
  33. */
  34. module.exports = CastError;