浏览代码

Log SchedulesDirect response on request error

Patrick Barron 1 年之前
父节点
当前提交
604f4b2742
共有 1 个文件被更改,包括 20 次插入4 次删除
  1. 20 4
      src/Jellyfin.LiveTv/Listings/SchedulesDirect.cs

+ 20 - 4
src/Jellyfin.LiveTv/Listings/SchedulesDirect.cs

@@ -608,6 +608,11 @@ namespace Jellyfin.LiveTv.Listings
 
             if (!enableRetry || (int)response.StatusCode >= 500)
             {
+                _logger.LogError(
+                    "Request to {Url} failed with response {Response}",
+                    message.RequestUri,
+                    await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false));
+
                 throw new HttpRequestException(
                     string.Format(CultureInfo.InvariantCulture, "Request failed: {0}", response.ReasonPhrase),
                     null,
@@ -655,11 +660,22 @@ namespace Jellyfin.LiveTv.Listings
             ArgumentException.ThrowIfNullOrEmpty(token);
             ArgumentException.ThrowIfNullOrEmpty(info.ListingsId);
 
-            _logger.LogInformation("Adding new LineUp ");
+            _logger.LogInformation("Adding new lineup {Id}", info.ListingsId);
 
-            using var options = new HttpRequestMessage(HttpMethod.Put, ApiUrl + "/lineups/" + info.ListingsId);
-            options.Headers.TryAddWithoutValidation("token", token);
-            using var response = await _httpClientFactory.CreateClient(NamedClient.Default).SendAsync(options, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+            using var message = new HttpRequestMessage(HttpMethod.Put, ApiUrl + "/lineups/" + info.ListingsId);
+            message.Headers.TryAddWithoutValidation("token", token);
+
+            using var client = _httpClientFactory.CreateClient(NamedClient.Default);
+            using var response = await client
+                .SendAsync(message, HttpCompletionOption.ResponseHeadersRead, cancellationToken)
+                .ConfigureAwait(false);
+
+            if (!response.IsSuccessStatusCode)
+            {
+                _logger.LogError(
+                    "Error adding lineup to account: {Response}",
+                    await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false));
+            }
         }
 
         private async Task<bool> HasLineup(ListingsProviderInfo info, CancellationToken cancellationToken)