From 5309d5fa7f2111faa834aec92026323f3e6ed50e Mon Sep 17 00:00:00 2001 From: Ben Olden-Cooligan Date: Sun, 7 Apr 2024 12:10:44 -0700 Subject: [PATCH] Escl: Throw DeviceOfflineException when a connection times out --- NAPS2.Sdk/Scan/Internal/Escl/EsclScanDriver.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NAPS2.Sdk/Scan/Internal/Escl/EsclScanDriver.cs b/NAPS2.Sdk/Scan/Internal/Escl/EsclScanDriver.cs index 9b7370a3f6..753b84ba43 100644 --- a/NAPS2.Sdk/Scan/Internal/Escl/EsclScanDriver.cs +++ b/NAPS2.Sdk/Scan/Internal/Escl/EsclScanDriver.cs @@ -141,6 +141,13 @@ public async Task GetDevices(ScanOptions options, CancellationToken cancelToken, throw; } } + catch (HttpRequestException ex) when (ex.InnerException is TaskCanceledException) + { + // A connection timeout manifests as TaskCanceledException + // TODO: Do we want to add a DeviceCommunicationException? It might be more appropriate here + // (and maps to WIA too) + throw new DeviceOfflineException(); + } catch (TaskCanceledException) { }