From 49367f1713c042fad5cac29ec8f0eaac5da4ddd2 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Mon, 1 Aug 2022 00:01:24 +0800 Subject: [PATCH] fix: handling rpc error on gateway (#2212) --- gateway/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gateway/server.go b/gateway/server.go index 80a44f0a..da155862 100644 --- a/gateway/server.go +++ b/gateway/server.go @@ -16,6 +16,7 @@ import ( "github.com/zeromicro/go-zero/rest" "github.com/zeromicro/go-zero/rest/httpx" "github.com/zeromicro/go-zero/zrpc" + "google.golang.org/grpc/codes" "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" ) @@ -135,6 +136,11 @@ func (s *Server) buildHandler(source grpcurl.DescriptorSource, resolver jsonpb.A handler, parser.Next); err != nil { httpx.Error(w, err) } + + st := handler.Status + if st.Code() != codes.OK { + httpx.Error(w, st.Err()) + } } }