From 9c42989ea79809cbb9fb7b916437d91e597bb62b Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 12 Oct 2022 19:03:03 +0200 Subject: [PATCH] Fix to throw error on file Closes GH-20. --- lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index f9acbc9..69bdace 100644 --- a/lib/index.js +++ b/lib/index.js @@ -64,7 +64,7 @@ export default function rehypeHighlight(options = {}) { name = pos > -1 ? prefix.slice(0, pos) : prefix } - return (tree) => { + return (tree, file) => { // eslint-disable-next-line complexity visit(tree, 'element', (node, _, givenParent) => { const parent = /** @type {Node?} */ (givenParent) @@ -108,7 +108,7 @@ export default function rehypeHighlight(options = {}) { } catch (error) { const exception = /** @type {Error} */ (error) if (!ignoreMissing || !/Unknown language/.test(exception.message)) { - throw error + file.fail(exception, node, 'rehype-highlight:missing-language') } return