From 4f3dfda487133617f4681df94956b8795c0c883c Mon Sep 17 00:00:00 2001 From: Rik Huijzer Date: Wed, 21 Feb 2024 11:45:40 +0100 Subject: [PATCH] More robust error throw & update Pluto (#179) Fixes https://github.com/rikhuijzer/PlutoStaticHTML.jl/issues/169 Also updates Pluto to 0.19.39. --- Project.toml | 4 ++-- src/output.jl | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index fa9f5dd..562c0b2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PlutoStaticHTML" uuid = "359b1769-a58e-495b-9770-312e911026ad" authors = ["Rik Huijzer "] -version = "6.0.19" +version = "6.0.20" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" @@ -20,7 +20,7 @@ tectonic_jll = "d7dd28d6-a5e6-559c-9131-7eb760cdacc5" [compat] AbstractTrees = "0.4" Gumbo = "0.8" -Pluto = "=0.19.37" +Pluto = "=0.19.39" PrecompileTools = "1.1" RelocatableFolders = "0.3, 1" julia = "1.6" diff --git a/src/output.jl b/src/output.jl index 6199ca3..2fbd66c 100644 --- a/src/output.jl +++ b/src/output.jl @@ -174,15 +174,19 @@ function _throw_if_error(session::ServerSession, nb::Notebook) continue end end + filename = _indent(nb.path) + code = _indent(cell.code) body = cell.output.body::Dict{Symbol,Any} msg = body[:msg]::String - val = body[:stacktrace]::CapturedException - io = IOBuffer() - ioc = IOContext(io, :color => Base.get_have_color()) - showerror(ioc, val) - error_text = _indent(String(take!(io))) - code = _indent(cell.code) - filename = _indent(nb.path) + error_text::String = if body[:stacktrace] isa CapturedException + val = body[:stacktrace]::CapturedException + io = IOBuffer() + ioc = IOContext(io, :color => Base.get_have_color()) + showerror(ioc, val) + _indent(String(take!(io))) + else + _indent(string(body[:stacktrace])::String) + end msg = """ Execution of notebook failed. Does the notebook show any errors when opening it in Pluto?