diff --git a/src/Literate.jl b/src/Literate.jl index 1111b45..1ffdc79 100644 --- a/src/Literate.jl +++ b/src/Literate.jl @@ -706,14 +706,16 @@ function execute_block(sb::Module, block::String) # Push a capturing display on the displaystack disp = LiterateDisplay() pushdisplay(disp) - # r is the result - # status = (true|false) - # _: backtrace - # str combined stdout, stderr output - c = IOCapture.capture(rethrow = InterruptException) do + # We use the following fields of the object returned by IOCapture.capture: + # - c.value: return value of the do-block (or the error object, if it throws) + # - c.error: set to `true` if the do-block throws an error + # - c.output: combined stdout and stderr + # `rethrow = Union{}` means that we try-catch all the exceptions thrown in the do-block + # and return them via the return value (they get handled below). + c = IOCapture.capture(rethrow = Union{}) do include_string(sb, block) end - popdisplay(disp) # Documenter.withoutput has a try-catch so should always end up here + popdisplay(disp) # IOCapture.capture has a try-catch so should always end up here if c.error error(""" $(sprint(showerror, c.value))