Skip to content

Commit

Permalink
Add additional unwrap code in ToStatusError gRPC error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
krapie committed Dec 30, 2022
1 parent a558c0f commit b12c8a9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/grpchelper/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ func detailsFromError(err error) (protoiface.MessageV1, bool) {
// occurs while executing logic in API handler, gRPC status.error should be
// returned so that the client can know more about the status of the request.
func ToStatusError(err error) error {
cause := errors.Unwrap(err)
if cause == nil {
cause = err
cause := err
for errors.Unwrap(cause) != nil {
cause = errors.Unwrap(cause)
}
if code, ok := errorToCode[cause]; ok {
return status.Error(code, err.Error())
Expand Down

0 comments on commit b12c8a9

Please sign in to comment.