cast.js 690 B

1234567891011121314151617181920212223242526272829303132333435363738
  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) {
  14. MongooseError.call(this, 'Cast to ' + type + ' failed for value "' + value + '" at path "' + path + '"');
  15. this.stack = new Error().stack;
  16. this.name = 'CastError';
  17. this.kind = type;
  18. this.value = value;
  19. this.path = path;
  20. };
  21. /*!
  22. * Inherits from MongooseError.
  23. */
  24. CastError.prototype = Object.create(MongooseError.prototype);
  25. CastError.prototype.constructor = MongooseError;
  26. /*!
  27. * exports
  28. */
  29. module.exports = CastError;