fix: message key in error detail (#503)

This commit is contained in:
Fabi 2020-07-22 11:29:43 +02:00 committed by GitHub
parent 117a0d7b19
commit 520cc161d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,16 +2,12 @@ package grpc
import (
"context"
"github.com/caos/logging"
"github.com/caos/zitadel/pkg/grpc/message"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/i18n"
"github.com/caos/zitadel/pkg/grpc/message"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func CaosToGRPCError(ctx context.Context, err error, translator *i18n.Translator) error {
@ -25,11 +21,12 @@ func CaosToGRPCError(ctx context.Context, err error, translator *i18n.Translator
msg := key
if translator != nil {
msg = translator.LocalizeFromCtx(ctx, key, nil)
msg += " (" + id + ")"
}
s, err := status.New(code, key).WithDetails(&message.ErrorDetail{Id: id, Message: msg})
s, err := status.New(code, msg).WithDetails(&message.ErrorDetail{Id: id, Message: key})
if err != nil {
logging.Log("GRPC-gIeRw").WithError(err).Debug("unable to add detail")
return status.New(code, key).Err()
return status.New(code, msg).Err()
}
return s.Err()