Skip to content

Commit 0ef45e5

Browse files
authored
Replace trivial uses of rethrow(exc) with rethrow() (#29794)
In all these cases we're merely rethrowing the existing exception, so it seems simpler and clearer just to use `rethrow()` without arguments. Previously it wasn't reliable to use `rethrow()` like this but the exception stack system from #29794 has fixed those problems.
1 parent 9eb2161 commit 0ef45e5

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/cluster.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function exec_conn_func(w::Worker)
136136
f()
137137
catch e
138138
w.conn_func = () -> throw(e)
139-
rethrow(e)
139+
rethrow()
140140
end
141141
nothing
142142
end
@@ -505,9 +505,9 @@ function create_worker(manager, wconfig)
505505
local r_s, w_s
506506
try
507507
(r_s, w_s) = connect(manager, w.id, wconfig)
508-
catch e
508+
catch
509509
deregister_worker(w.id)
510-
rethrow(e)
510+
rethrow()
511511
end
512512

513513
w = Worker(w.id, r_s, w_s, manager; config=wconfig)

src/clusterserialize.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function serialize_global_from_main(s::ClusterSerializer, sym)
159159
if isa(ex, ErrorException)
160160
record_v = false
161161
else
162-
rethrow(ex)
162+
rethrow()
163163
end
164164
end
165165
end

src/pmap.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pmap(f, c; retry_delays = zeros(3))
9393
Example: Retry `f` only if the exception is not of type `InexactError`, with exponentially increasing
9494
delays up to 3 times. Return a `NaN` in place for all `InexactError` occurrences.
9595
```julia
96-
pmap(f, c; on_error = e->(isa(e, InexactError) ? NaN : rethrow(e)), retry_delays = ExponentialBackOff(n = 3))
96+
pmap(f, c; on_error = e->(isa(e, InexactError) ? NaN : rethrow()), retry_delays = ExponentialBackOff(n = 3))
9797
```
9898
"""
9999
function pmap(f, p::AbstractWorkerPool, c; distributed=true, batch_size=1, on_error=nothing,
@@ -189,7 +189,7 @@ function wrap_batch(f, p, handle_errors)
189189
if handle_errors
190190
return Any[BatchProcessingError(b, e) for b in batch]
191191
else
192-
rethrow(e)
192+
rethrow()
193193
end
194194
end
195195
end

src/process_messages.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool)
227227
if (myid() == 1) && (wpid > 1)
228228
if oldstate != W_TERMINATING
229229
println(stderr, "Worker $wpid terminated.")
230-
rethrow(e)
230+
rethrow()
231231
end
232232
end
233233

test/distributed_exec.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ end
492492
pmap_args = [
493493
(:distributed, [:default, false]),
494494
(:batch_size, [:default,2]),
495-
(:on_error, [:default, e -> (e.msg == "foobar" ? true : rethrow(e))]),
495+
(:on_error, [:default, e -> (e.msg == "foobar" ? true : rethrow())]),
496496
(:retry_delays, [:default, fill(0.001, 1000)]),
497497
(:retry_check, [:default, (s,e) -> (s,endswith(e.msg,"foobar"))]),
498498
]
@@ -552,9 +552,9 @@ function walk_args(i)
552552

553553
try
554554
results_test(pmap(mapf, data; kwargs...))
555-
catch e
555+
catch
556556
println("pmap executing with args : ", kwargs)
557-
rethrow(e)
557+
rethrow()
558558
end
559559

560560
return
@@ -662,12 +662,12 @@ if Sys.isunix() # aka have ssh
662662
w_in_remote = sort(remotecall_fetch(workers, p))
663663
try
664664
@test intersect(new_pids, w_in_remote) == new_pids
665-
catch e
665+
catch
666666
print("p : $p\n")
667667
print("newpids : $new_pids\n")
668668
print("w_in_remote : $w_in_remote\n")
669669
print("intersect : $(intersect(new_pids, w_in_remote))\n\n\n")
670-
rethrow(e)
670+
rethrow()
671671
end
672672
end
673673

0 commit comments

Comments
 (0)