From 196fd9f521fb0d57abb6f705563f82d300415d97 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Tue, 14 Jun 2022 11:56:00 +0100 Subject: [PATCH] refactor(plugins): explicitly catch promise rejections --- src/plugins/embed-html-images/index.js | 4 +++- src/plugins/pdf-to-txt/index.js | 5 +++++ src/plugins/tidy-html/index.js | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/plugins/embed-html-images/index.js b/src/plugins/embed-html-images/index.js index 26e864d94..edcf6e4d4 100644 --- a/src/plugins/embed-html-images/index.js +++ b/src/plugins/embed-html-images/index.js @@ -36,7 +36,9 @@ async function plugin(server, options) { ) ); }) - ); + ).catch((err) => { + throw err; + }); return dom.serialize(); } diff --git a/src/plugins/pdf-to-txt/index.js b/src/plugins/pdf-to-txt/index.js index c2174f027..ec896c2f1 100644 --- a/src/plugins/pdf-to-txt/index.js +++ b/src/plugins/pdf-to-txt/index.js @@ -145,6 +145,11 @@ async function plugin(server, options) { .addJob("recognize", file) .then((result) => result?.data?.text) ) + ).catch( + /* istanbul ignore next: unable to test unknown errors */ + (err) => { + throw err; + } ); req.conversionResults.body = results.join(" "); diff --git a/src/plugins/tidy-html/index.js b/src/plugins/tidy-html/index.js index 89e30aac0..5b997038e 100644 --- a/src/plugins/tidy-html/index.js +++ b/src/plugins/tidy-html/index.js @@ -68,7 +68,12 @@ async function plugin(server) { sortAttributes: "alpha", }; - const results = await tidyP(parsedHtml, config); + const results = await tidyP(parsedHtml, config).catch( + /* istanbul ignore next: unable to test unknown errors */ + (err) => { + throw err; + } + ); return results; }