Skip to content

Commit

Permalink
Don't ignore getPlayers error. Return basic json formatted error.
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmacdonald committed Mar 23, 2024
1 parent 37d1bd8 commit bd925a7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tf2bdd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ func handleGetSteamIDs(database *sql.DB, config Config) http.HandlerFunc {

players, errPlayers := getPlayers(request.Context(), database)
if errPlayers != nil {
slog.Error("Failed to load players", slog.String("error", errPlayers.Error()))
writer.WriteHeader(http.StatusInternalServerError)
_, _ = writer.Write([]byte("error"))
if errEncode := json.NewEncoder(writer).Encode(map[string]string{
"error": "Could not load player list",
}); errEncode != nil {
slog.Error("failed to encode response", slog.String("error", errEncode.Error()))
}

return
}
Expand Down

0 comments on commit bd925a7

Please sign in to comment.