Skip to content

Commit 4b2e1b7

Browse files
committed
grpc: use errors.Is to check if error is Canceled
This improves behaviour when one error wraps another. Signed-off-by: Bryan Boreham <[email protected]>
1 parent e2613be commit 4b2e1b7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

grpc/cancel.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package grpc
22

33
import (
44
"context"
5+
"errors"
56

67
"google.golang.org/grpc/codes"
78
"google.golang.org/grpc/status"
89
)
910

1011
// IsCanceled checks whether an error comes from an operation being canceled
1112
func IsCanceled(err error) bool {
12-
if err == context.Canceled {
13+
if errors.Is(err, context.Canceled) {
1314
return true
1415
}
1516
s, ok := status.FromError(err)

0 commit comments

Comments
 (0)