From 9782b3261fc268881486d4f8ec1ca7ccd359fede Mon Sep 17 00:00:00 2001 From: carabasdaniel Date: Thu, 8 Jun 2023 10:37:59 +0300 Subject: [PATCH] If no grpc error details provided forward grpc error message --- errors.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/errors.go b/errors.go index e2b0ead..f535b49 100644 --- a/errors.go +++ b/errors.go @@ -271,6 +271,11 @@ func (e *AsertoError) WithHTTPStatus(httpStatus int) *AsertoError { // and if there are details from multiple errors, the aserto error will be constructed based on the first one. func FromGRPCStatus(grpcStatus status.Status) *AsertoError { var result *AsertoError + + if len(grpcStatus.Details()) == 0 { + return ErrUnknown.Msg(grpcStatus.Message()) + } + for _, detail := range grpcStatus.Details() { if t, ok := detail.(*errdetails.ErrorInfo); ok { result = asertoErrors[t.Domain] @@ -283,6 +288,7 @@ func FromGRPCStatus(grpcStatus status.Status) *AsertoError { break } } + return result }