grpc的状态码 https://github.com/grpc/grpc/bl ob/master/doc/statuscodes.md
1. python的异常处理
1. 服务端(server)
context.set_code(grpc.Status.NOT_FOUND)
context.set_details('记录不存在')
2. 客户端(client)
try:
stub.SayHello(Request())
print(rsp.status)
except grpc.RpcError as e:
2. go的异常处理
1. 服务端(server)
st := status.New(codes.InvalidArgument,"invalid username")
2. 客户端(client)
st,ok := status.FromError(err)
if !ok{
//Error was not a status error
}
st.Message()
st.Code()