Skip to content

Commit

Permalink
nit: invert if
Browse files Browse the repository at this point in the history
I couldn't follow theses too nested ifs.
  • Loading branch information
Jorropo committed Sep 5, 2023
1 parent 9b41d70 commit 7e0f5f5
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions compparallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,21 @@ func getValueOrErrorParallel[T any](
defer cancel()
value, empty, err := f(ctx, r.Router)
if err != nil {
if !errors.Is(err, routing.ErrNotFound) &&
!r.IgnoreError {
log.Debug("getValueOrErrorParallel: error calling router function for router ", r.Router,
" with timeout ", r.Timeout,
" and ignore errors ", r.IgnoreError,
" with error ", err,
)
select {
case <-ctx.Done():
case errCh <- err:
}
} else {
if r.IgnoreError || errors.Is(err, routing.ErrNotFound) {
log.Debug("getValueOrErrorParallel: not found or ignorable error for router ", r.Router,
" with timeout ", r.Timeout,
" and ignore errors ", r.IgnoreError,
)
return
}
log.Debug("getValueOrErrorParallel: error calling router function for router ", r.Router,
" with timeout ", r.Timeout,
" and ignore errors ", r.IgnoreError,
" with error ", err,
)
select {
case <-ctx.Done():
case errCh <- err:
}
return
}
Expand Down

0 comments on commit 7e0f5f5

Please sign in to comment.