From 23701531922a1769a2ed7108d21cd7b90c58c6a1 Mon Sep 17 00:00:00 2001 From: pcjones Date: Sun, 1 Feb 2026 17:51:47 +0100 Subject: [PATCH] Clarify error message on indexer request error --- .../Services/ProxyRequestService.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/UmlautAdaptarr/Services/ProxyRequestService.cs b/UmlautAdaptarr/Services/ProxyRequestService.cs index f136305..cca92f6 100644 --- a/UmlautAdaptarr/Services/ProxyRequestService.cs +++ b/UmlautAdaptarr/Services/ProxyRequestService.cs @@ -54,6 +54,7 @@ namespace UmlautAdaptarr.Services } await EnsureMinimumDelayAsync(targetUri); + var targetHost = new Uri(targetUri).Host; var requestMessage = new HttpRequestMessage { @@ -88,7 +89,14 @@ namespace UmlautAdaptarr.Services } catch (Exception ex) { - _logger.LogError(ex, $"Error proxying request: {UrlUtilities.RedactApiKey(targetUri)}. Error: {ex.Message}"); + var upstreamMessage = IsTimeoutOrReset(ex) + ? $"{targetHost} timed out or reset the connection. This is an error with your indexer or network, not with UmlautAdaptarr." + : $"{targetHost} request failed. This is an error with your indexer or network, not with UmlautAdaptarr."; + + _logger.LogError(ex, "{UpstreamMessage} Target: {TargetUri} Error: {ErrorMessage}", + upstreamMessage, + UrlUtilities.RedactApiKey(targetUri), + ex.Message); var errorResponse = new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError) { @@ -97,5 +105,26 @@ namespace UmlautAdaptarr.Services return errorResponse; } } + + private static bool IsTimeoutOrReset(Exception ex) + { + if (ex is TaskCanceledException) + { + return true; + } + + var current = ex; + while (current != null) + { + if (current is System.Net.Sockets.SocketException socketEx) + { + return socketEx.SocketErrorCode == System.Net.Sockets.SocketError.TimedOut + || socketEx.SocketErrorCode == System.Net.Sockets.SocketError.ConnectionReset; + } + current = current.InnerException; + } + + return false; + } } }