Created
May 16, 2018 01:32
-
-
Save euroelessar/dde1d70cf8e8fe8dd27a81d6b2b9025f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Status without details results to non-utf-8 string followed by percent-encoding. | |
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { | |
grpcStatus := status.New(codes.InvalidArgument, string([]byte{0xff, 0xfe, 0xfd})) | |
return nil, grpcStatus.Err() | |
} | |
// Adding detail to status results to panic. | |
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { | |
grpcStatus := status.New(codes.InvalidArgument, string([]byte{0xff, 0xfe, 0xfd})) | |
grpcStatus, err := grpcStatus.WithDetails(&pb.HelloRequest{}) | |
if err != nil { | |
return nil, err | |
} | |
return nil, grpcStatus.Err() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment