errors.js 913 B

12345678910111213141516171819202122232425262728293031
  1. // @ts-nocheck
  2. 'use strict';
  3. const PrettyError = require('pretty-error');
  4. const prettyError = new PrettyError();
  5. prettyError.withoutColors();
  6. prettyError.skipPackage('html-plugin-evaluation');
  7. prettyError.skipNodeFiles();
  8. prettyError.skip(function (traceLine) {
  9. return traceLine.path === 'html-plugin-evaluation';
  10. });
  11. module.exports = function (err, context) {
  12. return {
  13. toHtml: function () {
  14. return 'Html Webpack Plugin:\n<pre>\n' + this.toString() + '</pre>';
  15. },
  16. toJsonHtml: function () {
  17. return JSON.stringify(this.toHtml());
  18. },
  19. toString: function () {
  20. try {
  21. return prettyError.render(err).replace(/webpack:\/\/\/\./g, context);
  22. } catch (e) {
  23. // This can sometimes fail. We don't know why, but returning the
  24. // original error is better than returning the error thrown by
  25. // pretty-error.
  26. return err;
  27. }
  28. }
  29. };
  30. };