ValidationError.js 568 B

123456789101112131415161718192021222324252627282930
  1. /* eslint-disable
  2. strict,
  3. no-param-reassign
  4. */
  5. 'use strict';
  6. class ValidationError extends Error {
  7. constructor(errors, name) {
  8. super();
  9. this.name = 'ValidationError';
  10. this.message = `${name || ''} Invalid Options\n\n`;
  11. this.errors = errors.map((err) => {
  12. err.dataPath = err.dataPath.replace(/\//g, '.');
  13. return err;
  14. });
  15. this.errors.forEach((err) => {
  16. this.message += `options${err.dataPath} ${err.message}\n`;
  17. });
  18. Error.captureStackTrace(this, this.constructor);
  19. }
  20. }
  21. module.exports = ValidationError;