From c19b86e5ec99f781ceab6d7e51b0bab2250402a0 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Tue, 10 Feb 2026 18:31:20 -0500 Subject: [PATCH 1/3] Add error handling for result display Handle errors that happen when a result gets displayed in an example block (via `display_dict`). This often crops up when trying to latexify things, and the idea is that it should cause an error but not crash the doc build. I'm not sure how you are supposed to log the error such that `warnonly` specifiers will catch it, though, so some help there would be great. --- src/expander_pipeline.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/expander_pipeline.jl b/src/expander_pipeline.jl index aa7656a2fc8..d30eb213c84 100644 --- a/src/expander_pipeline.jl +++ b/src/expander_pipeline.jl @@ -905,7 +905,12 @@ function Selectors.runner(::Type{Expanders.ExampleBlocks}, node, page, doc) input = droplines(x.code) # Generate different in different formats and let each writer select - output = Base.invokelatest(Documenter.display_dict, result, context = :color => ansicolor) + output = try + Base.invokelatest(Documenter.display_dict, result, context = :color => ansicolor) + catch err + @error "Problem displaying result on page $(page.source): $(err)" + Dict(MIME"text/plain"(), "Error displaying result") + end # Remove references to gensym'd module from text/plain m = MIME"text/plain"() if haskey(output, m) From 249b9ce456c575f4ca19cf02c4425151d2fc6c7d Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Tue, 10 Feb 2026 22:46:57 -0500 Subject: [PATCH 2/3] Fix formatting and add changelog entry Co-Authored-By: Claude Opus 4.6 --- CHANGELOG.md | 4 ++++ src/expander_pipeline.jl | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd64d304eb4..9d0a56958c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Added `Remotes.Forgejo` for specifying a `Remote` hosted on a Forgejo instance (such as codeberg.org). ([#2857]) +### Fixed + +* Added error handling for `@example` block result display to avoid crashing when `display_dict` fails. ([#2876]) + ### Changed * reduced time complexity from O(n^2) to O(n) to improve the initial load time for search ([#2875]) diff --git a/src/expander_pipeline.jl b/src/expander_pipeline.jl index d30eb213c84..ade55e3dcd0 100644 --- a/src/expander_pipeline.jl +++ b/src/expander_pipeline.jl @@ -905,7 +905,7 @@ function Selectors.runner(::Type{Expanders.ExampleBlocks}, node, page, doc) input = droplines(x.code) # Generate different in different formats and let each writer select - output = try + output = try Base.invokelatest(Documenter.display_dict, result, context = :color => ansicolor) catch err @error "Problem displaying result on page $(page.source): $(err)" From 8a5417c6a3a2fb9ff572165a230e662804dbdb48 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Tue, 3 Mar 2026 11:59:33 -0500 Subject: [PATCH 3/3] Fix dict syntax for when an error happens during display --- src/expander_pipeline.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/expander_pipeline.jl b/src/expander_pipeline.jl index ade55e3dcd0..801516331d9 100644 --- a/src/expander_pipeline.jl +++ b/src/expander_pipeline.jl @@ -909,7 +909,7 @@ function Selectors.runner(::Type{Expanders.ExampleBlocks}, node, page, doc) Base.invokelatest(Documenter.display_dict, result, context = :color => ansicolor) catch err @error "Problem displaying result on page $(page.source): $(err)" - Dict(MIME"text/plain"(), "Error displaying result") + Dict(MIME"text/plain"() => "Error displaying result") end # Remove references to gensym'd module from text/plain m = MIME"text/plain"()