Skip to content

Commit

Permalink
Merge pull request #94 from Syriiin/better-beatmap-download-error-log…
Browse files Browse the repository at this point in the history
…ging

Log status code for beatmap download 5xx errors
  • Loading branch information
Syriiin authored Nov 7, 2024
2 parents dea8dbb + f3c4eb5 commit 1b84d1f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Difficalcy/Services/WebBeatmapProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ public async Task EnsureBeatmap(string beatmapId)
logger.LogInformation("Downloading beatmap {BeatmapId}", beatmapId);

using var response = await _httpClient.GetAsync($"https://osu.ppy.sh/osu/{beatmapId}");
if (!response.IsSuccessStatusCode || response.Content.Headers.ContentLength == 0)
if (!response.IsSuccessStatusCode)
{
logger.LogWarning("Failed to download beatmap {BeatmapId}", beatmapId);
logger.LogWarning("Failed to download beatmap {BeatmapId}, status code {StatusCode}", beatmapId, response.StatusCode);
throw new BeatmapNotFoundException(beatmapId);
}

if (response.Content.Headers.ContentLength == 0)
{
logger.LogWarning("Downloaded beatmap {BeatmapId} response was empty", beatmapId);
throw new BeatmapNotFoundException(beatmapId);
}

Expand Down

0 comments on commit 1b84d1f

Please sign in to comment.