Skip to content

Commit abbb997

Browse files
committed
Outline error path
1 parent 05c7f88 commit abbb997

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
@@ -117,6 +117,11 @@ function Base.show(io::IO, err::FeatureLevelError)
117117
print(io, "FeatureLevelError($(err.function_name)): Minimum MPI version is $(err.min_version)")
118118
end
119119

120+
@noinline function mpi_error(err)
121+
throw(MPIError(err))
122+
end
123+
124+
120125
macro mpichk(expr, min_version=nothing)
121126
if !isnothing(min_version) && expr.args[2].head == :tuple
122127
fn = expr.args[2].args[1].value
@@ -129,7 +134,13 @@ macro mpichk(expr, min_version=nothing)
129134

130135
expr = macroexpand(@__MODULE__, :(@mpicall($expr)))
131136
# MPI_SUCCESS is defined to be 0
132-
:((errcode = $(esc(expr))) == 0 || throw(MPIError(errcode)))
137+
quote
138+
errcode = $(esc(expr))
139+
if errcode != 0
140+
$mpi_error(errcode)
141+
end
142+
nothing
143+
end
133144
end
134145

135146

0 commit comments

Comments
 (0)