mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-23 00:51:29 +00:00
27 lines
422 B
Go
27 lines
422 B
Go
|
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
|
||
|
}
|