From cadbcc61b49716b5d87dbbe2b3fdaa26bf619eda Mon Sep 17 00:00:00 2001 From: Wil Simpson Date: Mon, 8 Apr 2024 20:51:21 -0400 Subject: [PATCH] fixed incorrect error messages and auth ctx --- pkg/srv/character.go | 14 ++++++++++---- pkg/srv/errors.go | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/srv/character.go b/pkg/srv/character.go index e3ce122..d707f35 100644 --- a/pkg/srv/character.go +++ b/pkg/srv/character.go @@ -209,7 +209,7 @@ func (s *charactersServiceServer) EditCharacter( char, err := s.server.CharacterService.FindByTarget(ctx, request.Target) if err != nil { log.Logger.WithContext(ctx).Errorf("edit character: %v", err) - return nil, status.Error(codes.Internal, "unable to character user") + return nil, ErrInternalEditCharacter } if request.OptionalNewName != nil && @@ -244,17 +244,23 @@ func (s *charactersServiceServer) EditCharacter( client, err := s.server.GetServerManagerClient() if err != nil { log.Logger.WithContext(ctx).Errorf("get dimension: %v", err) - return nil, ErrInternalCreateCharacter + return nil, ErrInternalEditCharacter } - dimension, err := client.GetDimension(ctx, request.GetDimension()) + authCtx, err := s.server.OutgoingClientAuth(ctx) + if err != nil { + log.Logger.WithContext(ctx).Errorf("outgoing client auth: %v", err) + return nil, ErrInternalEditCharacter + } + + dimension, err := client.GetDimension(authCtx, request.GetDimension()) if err != nil { if errors.Is(err, common.ErrDoesNotExist.Err()) { log.Logger.WithContext(ctx).Errorf("invalid dimension requested: %v", err) return nil, ErrInvalidDimension } log.Logger.WithContext(ctx).Errorf("get dimension: %v", err) - return nil, ErrInternalCreateCharacter + return nil, ErrInternalEditCharacter } char.Dimension = dimension.Name diff --git a/pkg/srv/errors.go b/pkg/srv/errors.go index 1e35f4a..ac0a72f 100644 --- a/pkg/srv/errors.go +++ b/pkg/srv/errors.go @@ -7,5 +7,6 @@ import ( var ( ErrInternalCreateCharacter = status.Error(codes.Internal, "unable to create character") + ErrInternalEditCharacter = status.Error(codes.Internal, "unable to edit character") ErrInvalidDimension = status.Error(codes.InvalidArgument, "invalid dimension requested") )