diff --git a/src/Literate.jl b/src/Literate.jl index ebd9cea..8f5ca2e 100644 --- a/src/Literate.jl +++ b/src/Literate.jl @@ -942,8 +942,8 @@ function execute_block(sb::Module, block::String; inputfile::String, fake_source if err isa LoadError # include_string may wrap error in LoadError err = err.error end - error_output = "ERROR: " * sprint(showerror, err) - return nothing, error_output, disp.data + all_output = c.output * "\n\nERROR: " * sprint(showerror, err) + return nothing, all_output, disp.data else error(""" $(sprint(showerror, c.value)) diff --git a/test/runtests.jl b/test/runtests.jl index f7df492..253de1d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1462,8 +1462,8 @@ end end @testset "continue_on_error=true" begin input_with_error = """ - # The following will error - + # The following will print something, then error + print("I always wanted to calculate") sqrt(-1.0) """ mktempdir(@__DIR__) do sandbox @@ -1471,6 +1471,7 @@ end end write(inputfile, input_with_error) Literate.markdown(inputfile, sandbox; continue_on_error = true, execute = true) output_md = read(joinpath(sandbox, "input.md"), String) + @test occursin("I always wanted to calculate", output_md) @test occursin("ERROR: DomainError with -1.0", output_md) end end