Skip to content

Commit

Permalink
Fix exception handling in test/examples/make.jl (#1363)
Browse files Browse the repository at this point in the history
Using throw() like this attaches the wrong backtrace to the exception.
Should be rethrow(), but you can only have that in catch blocks.

However, in this case, a simple try-finally actually suffices, no need
to do anything more complicated.
  • Loading branch information
mortenpi authored Jul 14, 2020
1 parent 676a8f0 commit 3e2090a
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions test/examples/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# or not and should be kept unique.
isdefined(@__MODULE__, :examples_root) && error("examples_root is already defined\n$(@__FILE__) included multiple times?")

# The `Mod` and `AutoDocs` modules are assumed to exists in the Main module.
# The `Mod` and `AutoDocs` modules are assumed to exist in the Main module.
(@__MODULE__) === Main || error("$(@__FILE__) must be included into Main.")

# DOCUMENTER_TEST_EXAMPLES environment variable can be used to control which
Expand Down Expand Up @@ -118,15 +118,14 @@ function withassets(f, assets...)
for asset in assets
cp(src(asset), dst(asset))
end
rv, exception = try
f(), nothing
catch e
nothing, e
try
f()
finally
@debug "Cleaning up assets" assets
for asset in assets
rm(dst(asset))
end
end
for asset in assets
rm(dst(asset))
end
return (exception === nothing) ? rv : throw(exception)
end

# Build example docs
Expand Down

0 comments on commit 3e2090a

Please sign in to comment.