Skip to content

Commit

Permalink
clarify comment
Browse files Browse the repository at this point in the history
  • Loading branch information
atollena committed Jun 28, 2023
1 parent 9a2ba92 commit d71350f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ func FromError(err error) (s *Status, ok bool) {
type grpcstatus interface{ GRPCStatus() *Status }
if gs, ok := err.(grpcstatus); ok {
if gs.GRPCStatus() == nil {
// Error has a status of OK. There is no sensible behavior for this, so map it to Unknown and discard the
// Error has status nil, which maps to codes.OK. There
// is no sensible behavior for this, so we turn it into
// an error with codes.Unknown and discard the existing
// status.
return New(codes.Unknown, err.Error()), false
}
Expand All @@ -109,8 +111,10 @@ func FromError(err error) (s *Status, ok bool) {
var gs grpcstatus
if errors.As(err, &gs) {
if gs.GRPCStatus() == nil {
// Error wraps an error that has an OK status. There is no sensible behavior for this, so map it to Unknown
// and discard the status.
// Error wraps an error that has status nil, which maps
// to codes.OK. There is no sensible behavior for this,
// so we turn it into an error with codes.Unknown and
// discard the existing status.
return New(codes.Unknown, err.Error()), false
}
p := gs.GRPCStatus().Proto()
Expand Down

0 comments on commit d71350f

Please sign in to comment.