Add grpc compatibility test

This commit is contained in:
世界
2022-08-29 10:10:41 +08:00
parent 665c84ee42
commit d440a01792
20 changed files with 458 additions and 154 deletions

26
common/baderror/grpc.go Normal file
View File

@@ -0,0 +1,26 @@
package baderror
import (
"context"
"io"
"net"
)
func WrapGRPC(err error) error {
// grpc uses stupid internal error types
if err == nil {
return nil
}
if Contains(err, "EOF") {
return io.EOF
}
if Contains(err, "Canceled") {
return context.Canceled
}
if Contains(err,
"the client connection is closing",
"server closed the stream without sending trailers") {
return net.ErrClosed
}
return err
}