Skip to content

Commit

Permalink
fixed incorrect error messages and auth ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
Wil Simpson committed Apr 9, 2024
1 parent ead70ce commit cadbcc6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/srv/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/srv/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

0 comments on commit cadbcc6

Please sign in to comment.