Skip to content

Commit 62c053a

Browse files
committed
Send gRPC error details also
1 parent de4ef56 commit 62c053a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

errors/errors.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"net/http"
77

8+
any "github.com/golang/protobuf/ptypes/any"
89
"google.golang.org/grpc/codes"
910
)
1011

@@ -101,8 +102,9 @@ func (e *ProxyError) WriteJSON(w io.Writer) error {
101102

102103
// GRPCError is an error returned by gRPC upstream
103104
type GRPCError struct {
104-
StatusCode int `json:"code"`
105-
Message string `json:"message"`
105+
StatusCode int `json:"code"`
106+
Message string `json:"message"`
107+
Details []*any.Any `json:"details,omitempty"`
106108
}
107109

108110
// HTTPStatusCode converts gRPC status codes to HTTP status codes

proxy/stub/stub.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func (s *stubImpl) InvokeRPC(
6464
return nil, &errors.GRPCError{
6565
StatusCode: int(stat.Code()),
6666
Message: stat.Message(),
67+
Details: stat.Proto().Details,
6768
}
6869
}
6970
outputMsg := invocation.MethodDescriptor.GetOutputType().NewMessage()

0 commit comments

Comments
 (0)