Skip to content

Commit

Permalink
Distributed: remove backtrace unwrapping from RemoteException (#37937)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash authored Oct 15, 2020
1 parent 89f0227 commit 676f6f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
2 changes: 1 addition & 1 deletion base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function showerror(io::IO, ex::CompositeException)
showerror(io, ex.exceptions[1])
remaining = length(ex) - 1
if remaining > 0
print(io, string("\n\n...and ", remaining, " more exception(s).\n"))
print(io, "\n\n...and ", remaining, " more exception", remaining > 1 ? "s" : "", ".\n")
end
else
print(io, "CompositeException()\n")
Expand Down
18 changes: 1 addition & 17 deletions stdlib/Distributed/src/process_messages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,7 @@ remote exception and a serializable form of the call stack when the exception wa
RemoteException(captured) = RemoteException(myid(), captured)
function showerror(io::IO, re::RemoteException)
(re.pid != myid()) && print(io, "On worker ", re.pid, ":\n")
showerror(io, get_root_exception(re.captured))
end

isa_exception_container(ex) = (isa(ex, RemoteException) ||
isa(ex, CapturedException) ||
isa(ex, CompositeException))

function get_root_exception(ex)
if isa(ex, RemoteException)
return get_root_exception(ex.captured)
elseif isa(ex, CapturedException) && isa_exception_container(ex.ex)
return get_root_exception(ex.ex)
elseif isa(ex, CompositeException) && length(ex.exceptions) > 0 && isa_exception_container(ex.exceptions[1])
return get_root_exception(ex.exceptions[1])
else
return ex
end
showerror(io, re.captured)
end

function run_work_thunk(thunk, print_error)
Expand Down
14 changes: 6 additions & 8 deletions stdlib/Distributed/test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ catch ex
# test showerror
err_str = sprint(showerror, ex)
err_one_str = sprint(showerror, ex.exceptions[1])
@test err_str == err_one_str * "\n\n...and 4 more exception(s).\n"
@test err_str == err_one_str * "\n\n...and 4 more exceptions.\n"
end
@test sprint(showerror, CompositeException()) == "CompositeException()\n"

Expand Down Expand Up @@ -1690,16 +1690,14 @@ let (h, t) = Distributed.head_and_tail(Int[], 0)
end

# issue #35937
let e
try
pmap(1) do _
let e = @test_throws RemoteException pmap(1) do _
wait(@async error(42))
end
catch ex
e = ex
end
# check that the inner TaskFailedException is correctly formed & can be printed
@test sprint(showerror, e) isa String
es = @show sprint(showerror, e.value)
@test contains(es, ":\nTaskFailedException\nStacktrace:\n")
@test contains(es, "\n\n nested task error:")
@test_broken contains(es, "\n\n nested task error: 42\n")
end

# issue #27429, propagate relative `include` path to workers
Expand Down

0 comments on commit 676f6f1

Please sign in to comment.