packages/grpcstatus/native_unwrap1.13+.go
raw| 1 | // +build go1.13 |
| 2 | |
| 3 | package grpcstatus |
| 4 | |
| 5 | import ( |
| 6 | "errors" |
| 7 | "google.golang.org/grpc/status" |
| 8 | ) |
| 9 | |
| 10 | func unwrapNativeWrappedGRPCStatus(err error) (*status.Status, bool) { |
| 11 | // Unwrapping the native Go unwrap interface |
| 12 | var unwrappedStatus gRPCStatus |
| 13 | if ok := errors.As(err, &unwrappedStatus); ok { |
| 14 | return unwrappedStatus.GRPCStatus(), true |
| 15 | } |
| 16 | return nil, false |
| 17 | } |