Skip to content

Commit

Permalink
feat: unwrap grpc status error before checking (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
23doors authored Jun 5, 2020
1 parent 45379dc commit f7338f8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,12 @@ func checkError(err, target error, code codes.Code) bool {
return true
}

s, ok := status.FromError(err)
var grpcstatus interface{ GRPCStatus() *status.Status }
if errors.As(err, &grpcstatus) {
return grpcstatus.GRPCStatus().Code() == code
}

return ok && s.Code() == code
return false
}

func IsContextError(err error) bool {
Expand Down

0 comments on commit f7338f8

Please sign in to comment.