Skip to content

1. grpc的状态码

https://github.com/grpc/grpc/blob/master/doc/statuscodes.md

2. go的异常处理

1. 服务端

go
st := status.New(codes.InvalidArgument, "invalid username")

2. 客户端

go
st, ok := status.FromError(err)
if !ok {
    // Error was not a status error
}
st.Message()
st.Code()