github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/grpcutil/errors.go (about) 1 package grpcutil 2 3 import ( 4 "errors" 5 6 "google.golang.org/grpc/status" 7 ) 8 9 // PeelAwayRPCErrorLayer peels away any intermediate RPC error layer from an 10 // error returned by gRPC-based code and constructs an error object using the 11 // underlying error message. If this unwrapping fails, the argument is returned 12 // directly. 13 func PeelAwayRPCErrorLayer(err error) error { 14 // Attempt to peel away the RPC layer. 15 if s, ok := status.FromError(err); ok { 16 return errors.New(s.Message()) 17 } 18 19 // Otherwise return the argument directly. 20 return err 21 }