From 2056139a9533ff9487506531491c0e5a94003607 Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Mon, 15 Oct 2018 00:39:44 -0700 Subject: [PATCH] fix: Catch and ignore pretty-error errors Fixes #921 --- lib/errors.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/errors.js b/lib/errors.js index c6cae4c8..7ed0636e 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -18,7 +18,14 @@ module.exports = function (err, context) { return JSON.stringify(this.toHtml()); }, toString: function () { - return prettyError.render(err).replace(/webpack:\/\/\/\./g, context); + try { + return prettyError.render(err).replace(/webpack:\/\/\/\./g, context); + } catch (e) { + // This can sometimes fail. We don't know why, but returning the + // original error is better than returning the error thrown by + // pretty-error. + return err; + } } }; };