Fix: linter complains

This commit is contained in:
Grail Finder
2025-07-05 13:33:34 +03:00
parent 913228844a
commit 5b24378956
3 changed files with 11 additions and 3 deletions

View File

@ -65,11 +65,11 @@ func getFullInfoByCtx(ctx context.Context) (*models.FullInfo, error) {
if err != nil {
// room was deleted; remove it from player;
log.Warn("failed to find room despite knowing room_id;",
"room_id", state.RoomID)
"room_id", state.RoomID, "error", err)
state.Team = models.UserTeamNone
state.Role = models.UserRoleNone
if err := repo.PlayerExitRoom(ctx, state.Username); err != nil {
log.Warn("failed to exit room",
log.Warn("failed to exit room", "error", err,
"room_id", state.RoomID, "username", state.Username)
return resp, err
}
@ -77,7 +77,11 @@ func getFullInfoByCtx(ctx context.Context) (*models.FullInfo, error) {
}
// get card_marks
if room.IsRunning && room.MimeDone {
fillCardMarks(ctx, room)
if err := fillCardMarks(ctx, room); err != nil {
log.Warn("failed to fill card marks", "error", err,
"room_id", state.RoomID, "username", state.Username)
return nil, err
}
}
resp.Room = room
return resp, nil

View File

@ -212,6 +212,7 @@ func HandleStartGame(w http.ResponseWriter, r *http.Request) {
}
if err := repo.RoomUpdate(ctx, fi.Room); err != nil {
log.Error("failed to update room", "error", err)
// nolint: errcheck
tx.Rollback()
abortWithError(w, err.Error())
return

View File

@ -153,16 +153,19 @@ func (b *Bot) checkGuess(word string, room *models.Room) error {
room.ActionHistory = append(room.ActionHistory, action)
}
ctx, tx, err := repo.InitTx(context.Background())
// nolint: errcheck
defer tx.Commit()
if err != nil {
b.log.Error("failed to init tx", "error", err)
}
if err := repo.ActionCreate(ctx, &action); err != nil {
// nolint: errcheck
tx.Rollback()
b.log.Error("failed to create action", "error", err, "action", action)
return err
}
if err := repo.RoomUpdate(ctx, room); err != nil {
// nolint: errcheck
tx.Rollback()
b.log.Error("failed to save room", "room", room)
err = fmt.Errorf("fn: checkGuess, failed to save room; err: %w", err)