grpc.go 422 B

1234567891011121314151617181920212223242526
  1. package baderror
  2. import (
  3. "context"
  4. "io"
  5. "net"
  6. )
  7. func WrapGRPC(err error) error {
  8. // grpc uses stupid internal error types
  9. if err == nil {
  10. return nil
  11. }
  12. if Contains(err, "EOF") {
  13. return io.EOF
  14. }
  15. if Contains(err, "Canceled") {
  16. return context.Canceled
  17. }
  18. if Contains(err,
  19. "the client connection is closing",
  20. "server closed the stream without sending trailers") {
  21. return net.ErrClosed
  22. }
  23. return err
  24. }