Skip to content

Commit

Permalink
placeholder - use pcall to catch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cscheid committed Jan 13, 2025
1 parent c17a257 commit c227734
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/resources/extensions/quarto/placeholder/placeholder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c227734

Please sign in to comment.