Skip to content

Commit d2d694e

Browse files
committed
Outline error path
1 parent 1c4b978 commit d2d694e

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/api/api.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ function Base.show(io::IO, err::FeatureLevelError)
122122
print(io, "FeatureLevelError($(err.function_name)): Minimum MPI version is $(err.min_version)")
123123
end
124124

125+
@noinline function mpi_error(err)
126+
throw(MPIError(err))
127+
end
128+
129+
125130
macro mpichk(expr, min_version=nothing)
126131
if !isnothing(min_version) && expr.args[2].head == :tuple
127132
fn = expr.args[2].args[1].value
@@ -134,7 +139,13 @@ macro mpichk(expr, min_version=nothing)
134139

135140
expr = macroexpand(@__MODULE__, :(@mpicall($expr)))
136141
# MPI_SUCCESS is defined to be 0
137-
:((errcode = $(esc(expr))) == 0 || throw(MPIError(errcode)))
142+
quote
143+
errcode = $(esc(expr))
144+
if errcode != 0
145+
$mpi_error(errcode)
146+
end
147+
nothing
148+
end
138149
end
139150

140151

0 commit comments

Comments
 (0)