ErrorToStatus returns a *github.com/gogo/status.Status representation of err. - If err implements the method `GRPCStatus() *google.golang.org/grpc/status.Status` and `GRPCStatus()` does not return nil, or if err wraps a type satisfying this, Status from `GRPCStatus()` is converted to gogo Status, a
(err error)
| 22 | // - Otherwise, err is an error not compatible with this function. In this |
| 23 | // case, a nil Status is returned and ok is false. |
| 24 | func ErrorToStatus(err error) (*status.Status, bool) { |
| 25 | if err == nil { |
| 26 | return nil, false |
| 27 | } |
| 28 | type grpcStatus interface{ GRPCStatus() *grpcstatus.Status } |
| 29 | var gs grpcStatus |
| 30 | if errors.As(err, &gs) { |
| 31 | st := gs.GRPCStatus() |
| 32 | if st == nil { |
| 33 | return nil, false |
| 34 | } |
| 35 | return status.FromGRPCStatus(st), true |
| 36 | } |
| 37 | return nil, false |
| 38 | } |
| 39 | |
| 40 | // ErrorToStatusCode extracts gRPC status code from error and returns it. |
| 41 | // |