Loading server/api_channel.go +3 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package server import ( "context" "github.com/heroiclabs/nakama-common/runtime" "github.com/gofrs/uuid" "github.com/heroiclabs/nakama-common/api" Loading Loading @@ -73,9 +74,9 @@ func (s *ApiServer) ListChannelMessages(ctx context.Context, in *api.ListChannel } messageList, err := ChannelMessagesList(ctx, s.logger, s.db, userID, streamConversionResult.Stream, in.ChannelId, limit, forward, in.Cursor) if err == ErrChannelCursorInvalid { if err == runtime.ErrChannelCursorInvalid { return nil, status.Error(codes.InvalidArgument, "Cursor is invalid or expired.") } else if err == ErrChannelGroupNotFound { } else if err == runtime.ErrChannelGroupNotFound { return nil, status.Error(codes.InvalidArgument, "Group not found.") } else if err != nil { return nil, status.Error(codes.Internal, "Error listing messages from channel.") Loading server/api_friend.go +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package server import ( "context" "github.com/heroiclabs/nakama-common/runtime" "strconv" "github.com/gofrs/uuid" Loading Loading @@ -69,7 +70,7 @@ func (s *ApiServer) ListFriends(ctx context.Context, in *api.ListFriendsRequest) friends, err := ListFriends(ctx, s.logger, s.db, s.tracker, userID, limit, state, in.GetCursor()) if err != nil { if err == ErrFriendInvalidCursor { if err == runtime.ErrFriendInvalidCursor { return nil, status.Error(codes.InvalidArgument, "Cursor is invalid.") } return nil, status.Error(codes.Internal, "Error while trying to list friends.") Loading server/api_group.go +20 −19 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package server import ( "context" "github.com/heroiclabs/nakama-common/runtime" "github.com/gofrs/uuid" "github.com/heroiclabs/nakama-common/api" Loading Loading @@ -65,7 +66,7 @@ func (s *ApiServer) CreateGroup(ctx context.Context, in *api.CreateGroupRequest) group, err := CreateGroup(ctx, s.logger, s.db, userID, userID, in.GetName(), in.GetLangTag(), in.GetDescription(), in.GetAvatarUrl(), "", in.GetOpen(), maxCount) if err != nil { if err == ErrGroupNameInUse { if err == runtime.ErrGroupNameInUse { return nil, status.Error(codes.AlreadyExists, "Group name is in use.") } return nil, status.Error(codes.Internal, "Error while trying to create group.") Loading Loading @@ -133,11 +134,11 @@ func (s *ApiServer) UpdateGroup(ctx context.Context, in *api.UpdateGroupRequest) err = UpdateGroup(ctx, s.logger, s.db, groupID, userID, uuid.Nil, in.GetName(), in.GetLangTag(), in.GetDescription(), in.GetAvatarUrl(), nil, in.GetOpen(), -1) if err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.NotFound, "Group not found or you're not allowed to update.") } else if err == ErrGroupNoUpdateOps { } else if err == runtime.ErrGroupNoUpdateOps { return nil, status.Error(codes.InvalidArgument, "Specify at least one field to update.") } else if err == ErrGroupNotUpdated { } else if err == runtime.ErrGroupNotUpdated { return nil, status.Error(codes.InvalidArgument, "No new fields in group update.") } return nil, status.Error(codes.Internal, "Error while trying to update group.") Loading Loading @@ -193,7 +194,7 @@ func (s *ApiServer) DeleteGroup(ctx context.Context, in *api.DeleteGroupRequest) err = DeleteGroup(ctx, s.logger, s.db, groupID, userID) if err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.InvalidArgument, "Group not found or you're not allowed to delete.") } return nil, status.Error(codes.Internal, "Error while trying to delete group.") Loading Loading @@ -250,9 +251,9 @@ func (s *ApiServer) JoinGroup(ctx context.Context, in *api.JoinGroupRequest) (*e err = JoinGroup(ctx, s.logger, s.db, s.router, groupID, userID, username) if err != nil { if err == ErrGroupNotFound { if err == runtime.ErrGroupNotFound { return nil, status.Error(codes.NotFound, "Group not found.") } else if err == ErrGroupFull { } else if err == runtime.ErrGroupFull { return nil, status.Error(codes.InvalidArgument, "Group is full.") } return nil, status.Error(codes.Internal, "Error while trying to join group.") Loading Loading @@ -309,7 +310,7 @@ func (s *ApiServer) LeaveGroup(ctx context.Context, in *api.LeaveGroupRequest) ( err = LeaveGroup(ctx, s.logger, s.db, s.router, groupID, userID, username) if err != nil { if err == ErrGroupLastSuperadmin { if err == runtime.ErrGroupLastSuperadmin { return nil, status.Error(codes.InvalidArgument, "Cannot leave group when you are the last superadmin.") } return nil, status.Error(codes.Internal, "Error while trying to leave group.") Loading Loading @@ -378,11 +379,11 @@ func (s *ApiServer) AddGroupUsers(ctx context.Context, in *api.AddGroupUsersRequ err = AddGroupUsers(ctx, s.logger, s.db, s.router, userID, groupID, userIDs) if err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.NotFound, "Group not found or permission denied.") } else if err == ErrGroupFull { } else if err == runtime.ErrGroupFull { return nil, status.Error(codes.InvalidArgument, "Group is full.") } else if err == ErrGroupUserNotFound { } else if err == runtime.ErrGroupUserNotFound { return nil, status.Error(codes.InvalidArgument, "One or more users not found.") } return nil, status.Error(codes.Internal, "Error while trying to add users to a group.") Loading Loading @@ -450,7 +451,7 @@ func (s *ApiServer) BanGroupUsers(ctx context.Context, in *api.BanGroupUsersRequ } if err = BanGroupUsers(ctx, s.logger, s.db, s.router, userID, groupID, userIDs); err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.NotFound, "Group not found or permission denied.") } return nil, status.Error(codes.Internal, "Error while trying to ban users from a group.") Loading Loading @@ -518,7 +519,7 @@ func (s *ApiServer) KickGroupUsers(ctx context.Context, in *api.KickGroupUsersRe } if err = KickGroupUsers(ctx, s.logger, s.db, s.router, userID, groupID, userIDs); err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.NotFound, "Group not found or permission denied.") } return nil, status.Error(codes.Internal, "Error while trying to kick users from a group.") Loading Loading @@ -587,9 +588,9 @@ func (s *ApiServer) PromoteGroupUsers(ctx context.Context, in *api.PromoteGroupU err = PromoteGroupUsers(ctx, s.logger, s.db, s.router, userID, groupID, userIDs) if err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.NotFound, "Group not found or permission denied.") } else if err == ErrGroupFull { } else if err == runtime.ErrGroupFull { return nil, status.Error(codes.InvalidArgument, "Group is full.") } return nil, status.Error(codes.Internal, "Error while trying to promote users in a group.") Loading Loading @@ -658,7 +659,7 @@ func (s *ApiServer) ListGroupUsers(ctx context.Context, in *api.ListGroupUsersRe groupUsers, err := ListGroupUsers(ctx, s.logger, s.db, s.tracker, groupID, limit, state, in.GetCursor()) if err != nil { if err == ErrGroupUserInvalidCursor { if err == runtime.ErrGroupUserInvalidCursor { return nil, status.Error(codes.InvalidArgument, "Cursor is invalid.") } return nil, status.Error(codes.Internal, "Error while trying to list users in a group.") Loading Loading @@ -727,9 +728,9 @@ func (s *ApiServer) DemoteGroupUsers(ctx context.Context, in *api.DemoteGroupUse err = DemoteGroupUsers(ctx, s.logger, s.db, s.router, userID, groupID, userIDs) if err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.NotFound, "Group not found or permission denied.") } else if err == ErrGroupFull { } else if err == runtime.ErrGroupFull { return nil, status.Error(codes.InvalidArgument, "Group is full.") } return nil, status.Error(codes.Internal, "Error while trying to demote users in a group.") Loading Loading @@ -798,7 +799,7 @@ func (s *ApiServer) ListUserGroups(ctx context.Context, in *api.ListUserGroupsRe userGroups, err := ListUserGroups(ctx, s.logger, s.db, userID, limit, state, in.GetCursor()) if err != nil { if err == ErrUserGroupInvalidCursor { if err == runtime.ErrUserGroupInvalidCursor { return nil, status.Error(codes.InvalidArgument, "Cursor is invalid.") } return nil, status.Error(codes.Internal, "Error while trying to list groups for a user.") Loading server/api_tournament.go +11 −10 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import ( "encoding/base64" "encoding/gob" "encoding/json" "github.com/heroiclabs/nakama-common/runtime" "time" "github.com/gofrs/uuid" Loading Loading @@ -61,11 +62,11 @@ func (s *ApiServer) JoinTournament(ctx context.Context, in *api.JoinTournamentRe tournamentID := in.GetTournamentId() if err := TournamentJoin(ctx, s.logger, s.db, s.leaderboardCache, userID.String(), username, tournamentID); err != nil { if err == ErrTournamentNotFound { if err == runtime.ErrTournamentNotFound { return nil, status.Error(codes.NotFound, "Tournament not found.") } else if err == ErrTournamentMaxSizeReached { } else if err == runtime.ErrTournamentMaxSizeReached { return nil, status.Error(codes.InvalidArgument, "Tournament cannot be joined as it has reached its max size.") } else if err == ErrTournamentOutsideDuration { } else if err == runtime.ErrTournamentOutsideDuration { return nil, status.Error(codes.InvalidArgument, "Tournament is not active and cannot accept new joins.") } return nil, status.Error(codes.Internal, "Error while trying to join tournament.") Loading Loading @@ -136,9 +137,9 @@ func (s *ApiServer) ListTournamentRecords(ctx context.Context, in *api.ListTourn } recordList, err := TournamentRecordsList(ctx, s.logger, s.db, s.leaderboardCache, s.leaderboardRankCache, in.GetTournamentId(), in.OwnerIds, limit, in.Cursor, overrideExpiry) if err == ErrTournamentNotFound { if err == runtime.ErrTournamentNotFound { return nil, status.Error(codes.NotFound, "Tournament not found.") } else if err == ErrTournamentOutsideDuration { } else if err == runtime.ErrTournamentOutsideDuration { return nil, status.Error(codes.NotFound, "Tournament has ended.") } else if err == ErrLeaderboardInvalidCursor { return nil, status.Error(codes.InvalidArgument, "Cursor is invalid or expired.") Loading Loading @@ -300,15 +301,15 @@ func (s *ApiServer) WriteTournamentRecord(ctx context.Context, in *api.WriteTour record, err := TournamentRecordWrite(ctx, s.logger, s.db, s.leaderboardCache, s.leaderboardRankCache, userID, in.GetTournamentId(), userID, username, in.GetRecord().GetScore(), in.GetRecord().GetSubscore(), in.GetRecord().GetMetadata(), in.GetRecord().GetOperator()) if err != nil { if err == ErrTournamentMaxSizeReached { if err == runtime.ErrTournamentMaxSizeReached { return nil, status.Error(codes.FailedPrecondition, "Tournament has reached max size.") } else if err == ErrTournamentAuthoritative { } else if err == runtime.ErrTournamentAuthoritative { return nil, status.Error(codes.PermissionDenied, "Tournament only allows authoritative score submissions.") } else if err == ErrTournamentWriteMaxNumScoreReached { } else if err == runtime.ErrTournamentWriteMaxNumScoreReached { return nil, status.Error(codes.FailedPrecondition, "Reached allowed max number of score attempts.") } else if err == ErrTournamentWriteJoinRequired { } else if err == runtime.ErrTournamentWriteJoinRequired { return nil, status.Error(codes.FailedPrecondition, "Must join tournament before attempting to write value.") } else if err == ErrTournamentOutsideDuration { } else if err == runtime.ErrTournamentOutsideDuration { return nil, status.Error(codes.FailedPrecondition, "Tournament is not active and cannot accept new scores.") } else { return nil, status.Error(codes.Internal, "Error writing score to tournament.") Loading server/console_match.go +3 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package server import ( "context" "github.com/heroiclabs/nakama-common/runtime" "strings" "github.com/gofrs/uuid" Loading Loading @@ -79,10 +80,10 @@ func (s *ConsoleServer) GetMatchState(ctx context.Context, in *console.MatchStat presences, tick, state, err := s.matchRegistry.GetState(ctx, matchID, node) if err != nil { if err != context.Canceled && err != ErrMatchNotFound { if err != context.Canceled && err != runtime.ErrMatchNotFound { s.logger.Error("Error getting match state.", zap.Any("in", in), zap.Error(err)) } if err == ErrMatchNotFound { if err == runtime.ErrMatchNotFound { return nil, status.Error(codes.InvalidArgument, "Match not found, or match handler already stopped.") } return nil, status.Error(codes.Internal, "Error listing matches.") Loading Loading
server/api_channel.go +3 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package server import ( "context" "github.com/heroiclabs/nakama-common/runtime" "github.com/gofrs/uuid" "github.com/heroiclabs/nakama-common/api" Loading Loading @@ -73,9 +74,9 @@ func (s *ApiServer) ListChannelMessages(ctx context.Context, in *api.ListChannel } messageList, err := ChannelMessagesList(ctx, s.logger, s.db, userID, streamConversionResult.Stream, in.ChannelId, limit, forward, in.Cursor) if err == ErrChannelCursorInvalid { if err == runtime.ErrChannelCursorInvalid { return nil, status.Error(codes.InvalidArgument, "Cursor is invalid or expired.") } else if err == ErrChannelGroupNotFound { } else if err == runtime.ErrChannelGroupNotFound { return nil, status.Error(codes.InvalidArgument, "Group not found.") } else if err != nil { return nil, status.Error(codes.Internal, "Error listing messages from channel.") Loading
server/api_friend.go +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package server import ( "context" "github.com/heroiclabs/nakama-common/runtime" "strconv" "github.com/gofrs/uuid" Loading Loading @@ -69,7 +70,7 @@ func (s *ApiServer) ListFriends(ctx context.Context, in *api.ListFriendsRequest) friends, err := ListFriends(ctx, s.logger, s.db, s.tracker, userID, limit, state, in.GetCursor()) if err != nil { if err == ErrFriendInvalidCursor { if err == runtime.ErrFriendInvalidCursor { return nil, status.Error(codes.InvalidArgument, "Cursor is invalid.") } return nil, status.Error(codes.Internal, "Error while trying to list friends.") Loading
server/api_group.go +20 −19 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package server import ( "context" "github.com/heroiclabs/nakama-common/runtime" "github.com/gofrs/uuid" "github.com/heroiclabs/nakama-common/api" Loading Loading @@ -65,7 +66,7 @@ func (s *ApiServer) CreateGroup(ctx context.Context, in *api.CreateGroupRequest) group, err := CreateGroup(ctx, s.logger, s.db, userID, userID, in.GetName(), in.GetLangTag(), in.GetDescription(), in.GetAvatarUrl(), "", in.GetOpen(), maxCount) if err != nil { if err == ErrGroupNameInUse { if err == runtime.ErrGroupNameInUse { return nil, status.Error(codes.AlreadyExists, "Group name is in use.") } return nil, status.Error(codes.Internal, "Error while trying to create group.") Loading Loading @@ -133,11 +134,11 @@ func (s *ApiServer) UpdateGroup(ctx context.Context, in *api.UpdateGroupRequest) err = UpdateGroup(ctx, s.logger, s.db, groupID, userID, uuid.Nil, in.GetName(), in.GetLangTag(), in.GetDescription(), in.GetAvatarUrl(), nil, in.GetOpen(), -1) if err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.NotFound, "Group not found or you're not allowed to update.") } else if err == ErrGroupNoUpdateOps { } else if err == runtime.ErrGroupNoUpdateOps { return nil, status.Error(codes.InvalidArgument, "Specify at least one field to update.") } else if err == ErrGroupNotUpdated { } else if err == runtime.ErrGroupNotUpdated { return nil, status.Error(codes.InvalidArgument, "No new fields in group update.") } return nil, status.Error(codes.Internal, "Error while trying to update group.") Loading Loading @@ -193,7 +194,7 @@ func (s *ApiServer) DeleteGroup(ctx context.Context, in *api.DeleteGroupRequest) err = DeleteGroup(ctx, s.logger, s.db, groupID, userID) if err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.InvalidArgument, "Group not found or you're not allowed to delete.") } return nil, status.Error(codes.Internal, "Error while trying to delete group.") Loading Loading @@ -250,9 +251,9 @@ func (s *ApiServer) JoinGroup(ctx context.Context, in *api.JoinGroupRequest) (*e err = JoinGroup(ctx, s.logger, s.db, s.router, groupID, userID, username) if err != nil { if err == ErrGroupNotFound { if err == runtime.ErrGroupNotFound { return nil, status.Error(codes.NotFound, "Group not found.") } else if err == ErrGroupFull { } else if err == runtime.ErrGroupFull { return nil, status.Error(codes.InvalidArgument, "Group is full.") } return nil, status.Error(codes.Internal, "Error while trying to join group.") Loading Loading @@ -309,7 +310,7 @@ func (s *ApiServer) LeaveGroup(ctx context.Context, in *api.LeaveGroupRequest) ( err = LeaveGroup(ctx, s.logger, s.db, s.router, groupID, userID, username) if err != nil { if err == ErrGroupLastSuperadmin { if err == runtime.ErrGroupLastSuperadmin { return nil, status.Error(codes.InvalidArgument, "Cannot leave group when you are the last superadmin.") } return nil, status.Error(codes.Internal, "Error while trying to leave group.") Loading Loading @@ -378,11 +379,11 @@ func (s *ApiServer) AddGroupUsers(ctx context.Context, in *api.AddGroupUsersRequ err = AddGroupUsers(ctx, s.logger, s.db, s.router, userID, groupID, userIDs) if err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.NotFound, "Group not found or permission denied.") } else if err == ErrGroupFull { } else if err == runtime.ErrGroupFull { return nil, status.Error(codes.InvalidArgument, "Group is full.") } else if err == ErrGroupUserNotFound { } else if err == runtime.ErrGroupUserNotFound { return nil, status.Error(codes.InvalidArgument, "One or more users not found.") } return nil, status.Error(codes.Internal, "Error while trying to add users to a group.") Loading Loading @@ -450,7 +451,7 @@ func (s *ApiServer) BanGroupUsers(ctx context.Context, in *api.BanGroupUsersRequ } if err = BanGroupUsers(ctx, s.logger, s.db, s.router, userID, groupID, userIDs); err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.NotFound, "Group not found or permission denied.") } return nil, status.Error(codes.Internal, "Error while trying to ban users from a group.") Loading Loading @@ -518,7 +519,7 @@ func (s *ApiServer) KickGroupUsers(ctx context.Context, in *api.KickGroupUsersRe } if err = KickGroupUsers(ctx, s.logger, s.db, s.router, userID, groupID, userIDs); err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.NotFound, "Group not found or permission denied.") } return nil, status.Error(codes.Internal, "Error while trying to kick users from a group.") Loading Loading @@ -587,9 +588,9 @@ func (s *ApiServer) PromoteGroupUsers(ctx context.Context, in *api.PromoteGroupU err = PromoteGroupUsers(ctx, s.logger, s.db, s.router, userID, groupID, userIDs) if err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.NotFound, "Group not found or permission denied.") } else if err == ErrGroupFull { } else if err == runtime.ErrGroupFull { return nil, status.Error(codes.InvalidArgument, "Group is full.") } return nil, status.Error(codes.Internal, "Error while trying to promote users in a group.") Loading Loading @@ -658,7 +659,7 @@ func (s *ApiServer) ListGroupUsers(ctx context.Context, in *api.ListGroupUsersRe groupUsers, err := ListGroupUsers(ctx, s.logger, s.db, s.tracker, groupID, limit, state, in.GetCursor()) if err != nil { if err == ErrGroupUserInvalidCursor { if err == runtime.ErrGroupUserInvalidCursor { return nil, status.Error(codes.InvalidArgument, "Cursor is invalid.") } return nil, status.Error(codes.Internal, "Error while trying to list users in a group.") Loading Loading @@ -727,9 +728,9 @@ func (s *ApiServer) DemoteGroupUsers(ctx context.Context, in *api.DemoteGroupUse err = DemoteGroupUsers(ctx, s.logger, s.db, s.router, userID, groupID, userIDs) if err != nil { if err == ErrGroupPermissionDenied { if err == runtime.ErrGroupPermissionDenied { return nil, status.Error(codes.NotFound, "Group not found or permission denied.") } else if err == ErrGroupFull { } else if err == runtime.ErrGroupFull { return nil, status.Error(codes.InvalidArgument, "Group is full.") } return nil, status.Error(codes.Internal, "Error while trying to demote users in a group.") Loading Loading @@ -798,7 +799,7 @@ func (s *ApiServer) ListUserGroups(ctx context.Context, in *api.ListUserGroupsRe userGroups, err := ListUserGroups(ctx, s.logger, s.db, userID, limit, state, in.GetCursor()) if err != nil { if err == ErrUserGroupInvalidCursor { if err == runtime.ErrUserGroupInvalidCursor { return nil, status.Error(codes.InvalidArgument, "Cursor is invalid.") } return nil, status.Error(codes.Internal, "Error while trying to list groups for a user.") Loading
server/api_tournament.go +11 −10 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import ( "encoding/base64" "encoding/gob" "encoding/json" "github.com/heroiclabs/nakama-common/runtime" "time" "github.com/gofrs/uuid" Loading Loading @@ -61,11 +62,11 @@ func (s *ApiServer) JoinTournament(ctx context.Context, in *api.JoinTournamentRe tournamentID := in.GetTournamentId() if err := TournamentJoin(ctx, s.logger, s.db, s.leaderboardCache, userID.String(), username, tournamentID); err != nil { if err == ErrTournamentNotFound { if err == runtime.ErrTournamentNotFound { return nil, status.Error(codes.NotFound, "Tournament not found.") } else if err == ErrTournamentMaxSizeReached { } else if err == runtime.ErrTournamentMaxSizeReached { return nil, status.Error(codes.InvalidArgument, "Tournament cannot be joined as it has reached its max size.") } else if err == ErrTournamentOutsideDuration { } else if err == runtime.ErrTournamentOutsideDuration { return nil, status.Error(codes.InvalidArgument, "Tournament is not active and cannot accept new joins.") } return nil, status.Error(codes.Internal, "Error while trying to join tournament.") Loading Loading @@ -136,9 +137,9 @@ func (s *ApiServer) ListTournamentRecords(ctx context.Context, in *api.ListTourn } recordList, err := TournamentRecordsList(ctx, s.logger, s.db, s.leaderboardCache, s.leaderboardRankCache, in.GetTournamentId(), in.OwnerIds, limit, in.Cursor, overrideExpiry) if err == ErrTournamentNotFound { if err == runtime.ErrTournamentNotFound { return nil, status.Error(codes.NotFound, "Tournament not found.") } else if err == ErrTournamentOutsideDuration { } else if err == runtime.ErrTournamentOutsideDuration { return nil, status.Error(codes.NotFound, "Tournament has ended.") } else if err == ErrLeaderboardInvalidCursor { return nil, status.Error(codes.InvalidArgument, "Cursor is invalid or expired.") Loading Loading @@ -300,15 +301,15 @@ func (s *ApiServer) WriteTournamentRecord(ctx context.Context, in *api.WriteTour record, err := TournamentRecordWrite(ctx, s.logger, s.db, s.leaderboardCache, s.leaderboardRankCache, userID, in.GetTournamentId(), userID, username, in.GetRecord().GetScore(), in.GetRecord().GetSubscore(), in.GetRecord().GetMetadata(), in.GetRecord().GetOperator()) if err != nil { if err == ErrTournamentMaxSizeReached { if err == runtime.ErrTournamentMaxSizeReached { return nil, status.Error(codes.FailedPrecondition, "Tournament has reached max size.") } else if err == ErrTournamentAuthoritative { } else if err == runtime.ErrTournamentAuthoritative { return nil, status.Error(codes.PermissionDenied, "Tournament only allows authoritative score submissions.") } else if err == ErrTournamentWriteMaxNumScoreReached { } else if err == runtime.ErrTournamentWriteMaxNumScoreReached { return nil, status.Error(codes.FailedPrecondition, "Reached allowed max number of score attempts.") } else if err == ErrTournamentWriteJoinRequired { } else if err == runtime.ErrTournamentWriteJoinRequired { return nil, status.Error(codes.FailedPrecondition, "Must join tournament before attempting to write value.") } else if err == ErrTournamentOutsideDuration { } else if err == runtime.ErrTournamentOutsideDuration { return nil, status.Error(codes.FailedPrecondition, "Tournament is not active and cannot accept new scores.") } else { return nil, status.Error(codes.Internal, "Error writing score to tournament.") Loading
server/console_match.go +3 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package server import ( "context" "github.com/heroiclabs/nakama-common/runtime" "strings" "github.com/gofrs/uuid" Loading Loading @@ -79,10 +80,10 @@ func (s *ConsoleServer) GetMatchState(ctx context.Context, in *console.MatchStat presences, tick, state, err := s.matchRegistry.GetState(ctx, matchID, node) if err != nil { if err != context.Canceled && err != ErrMatchNotFound { if err != context.Canceled && err != runtime.ErrMatchNotFound { s.logger.Error("Error getting match state.", zap.Any("in", in), zap.Error(err)) } if err == ErrMatchNotFound { if err == runtime.ErrMatchNotFound { return nil, status.Error(codes.InvalidArgument, "Match not found, or match handler already stopped.") } return nil, status.Error(codes.Internal, "Error listing matches.") Loading