From c22773474c83825e61fa9240eb17f6ad991de1f3 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Mon, 13 Jan 2025 13:52:40 -0500 Subject: [PATCH] placeholder - use pcall to catch errors --- .../extensions/quarto/placeholder/placeholder.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/resources/extensions/quarto/placeholder/placeholder.lua b/src/resources/extensions/quarto/placeholder/placeholder.lua index c6ba0d8297..725be5bc25 100644 --- a/src/resources/extensions/quarto/placeholder/placeholder.lua +++ b/src/resources/extensions/quarto/placeholder/placeholder.lua @@ -25,7 +25,15 @@ return { if output_format == "svg" then result = svg64 else - local mt, contents = pandoc.mediabag.fetch("https://svg2png.deno.dev/" .. svg64) + local pcallresult, mt, contents = pcall(function() + local mt, contents = pandoc.mediabag.fetch("https://svg2png.deno.dev/" .. svg64) + return mt, contents + end) + if not pcallresult then + error("Error rendering placeholder") + error(contents) + return pandoc.Str("Error rendering placeholder") + end if mt ~= "image/png" then error("Expected image/png but got " .. mt) error(contents)