objectParameter.js 884 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*!
  2. * Module dependencies.
  3. */
  4. 'use strict';
  5. const MongooseError = require('./');
  6. /**
  7. * Constructor for errors that happen when a parameter that's expected to be
  8. * an object isn't an object
  9. *
  10. * @param {Any} value
  11. * @param {String} paramName
  12. * @param {String} fnName
  13. * @inherits MongooseError
  14. * @api private
  15. */
  16. function ObjectParameterError(value, paramName, fnName) {
  17. MongooseError.call(this, 'Parameter "' + paramName + '" to ' + fnName +
  18. '() must be an object, got ' + value.toString());
  19. this.name = 'ObjectParameterError';
  20. if (Error.captureStackTrace) {
  21. Error.captureStackTrace(this);
  22. } else {
  23. this.stack = new Error().stack;
  24. }
  25. }
  26. /*!
  27. * Inherits from MongooseError.
  28. */
  29. ObjectParameterError.prototype = Object.create(MongooseError.prototype);
  30. ObjectParameterError.prototype.constructor = MongooseError;
  31. module.exports = ObjectParameterError;