Skip to content

Commit d1bfaba

Browse files
committed
fix: capture error correctly in withConn
1 parent f1d6bc9 commit d1bfaba

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

redis.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,9 @@ func (c *baseClient) withConn(
288288
return err
289289
}
290290

291-
defer func() {
292-
c.releaseConn(ctx, cn, err)
293-
}()
294-
295-
return fn(ctx, cn)
291+
err = fn(ctx, cn)
292+
c.releaseConn(ctx, cn, err)
293+
return err
296294
}
297295

298296
func (c *baseClient) dial(ctx context.Context, network, addr string) (net.Conn, error) {

0 commit comments

Comments
 (0)