Skip to content

Commit bdde937

Browse files
Merge pull request #6 from aserto-dev/grpcerrorfix
If no grpc error details provided forward error message
2 parents 9d92492 + 9782b32 commit bdde937

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

errors.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ func (e *AsertoError) WithHTTPStatus(httpStatus int) *AsertoError {
271271
// and if there are details from multiple errors, the aserto error will be constructed based on the first one.
272272
func FromGRPCStatus(grpcStatus status.Status) *AsertoError {
273273
var result *AsertoError
274+
275+
if len(grpcStatus.Details()) == 0 {
276+
return ErrUnknown.Msg(grpcStatus.Message())
277+
}
278+
274279
for _, detail := range grpcStatus.Details() {
275280
if t, ok := detail.(*errdetails.ErrorInfo); ok {
276281
result = asertoErrors[t.Domain]
@@ -283,6 +288,7 @@ func FromGRPCStatus(grpcStatus status.Status) *AsertoError {
283288
break
284289
}
285290
}
291+
286292
return result
287293
}
288294

0 commit comments

Comments
 (0)