aboutsummaryrefslogtreecommitdiff
path: root/vendor/google.golang.org/grpc/status
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org/grpc/status')
-rw-r--r--vendor/google.golang.org/grpc/status/status.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/vendor/google.golang.org/grpc/status/status.go b/vendor/google.golang.org/grpc/status/status.go
index af2cffe98..6d163b6e3 100644
--- a/vendor/google.golang.org/grpc/status/status.go
+++ b/vendor/google.golang.org/grpc/status/status.go
@@ -29,6 +29,7 @@ package status
import (
"context"
+ "errors"
"fmt"
spb "google.golang.org/genproto/googleapis/rpc/status"
@@ -117,18 +118,18 @@ func Code(err error) codes.Code {
return codes.Unknown
}
-// FromContextError converts a context error into a Status. It returns a
-// Status with codes.OK if err is nil, or a Status with codes.Unknown if err is
-// non-nil and not a context error.
+// FromContextError converts a context error or wrapped context error into a
+// Status. It returns a Status with codes.OK if err is nil, or a Status with
+// codes.Unknown if err is non-nil and not a context error.
func FromContextError(err error) *Status {
- switch err {
- case nil:
+ if err == nil {
return nil
- case context.DeadlineExceeded:
+ }
+ if errors.Is(err, context.DeadlineExceeded) {
return New(codes.DeadlineExceeded, err.Error())
- case context.Canceled:
+ }
+ if errors.Is(err, context.Canceled) {
return New(codes.Canceled, err.Error())
- default:
- return New(codes.Unknown, err.Error())
}
+ return New(codes.Unknown, err.Error())
}