Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Fixed identifying root-cause exceptions.

nzbdav-dev326be3fbf4a6
diff --git a/backend/Clients/Usenet/MultiConnectionNntpClient.cs b/backend/Clients/Usenet/MultiConnectionNntpClient.cs
index b5fb7cf1..ad7a971f 100644
--- a/backend/Clients/Usenet/MultiConnectionNntpClient.cs
+++ b/backend/Clients/Usenet/MultiConnectionNntpClient.cs
@@ -194,13 +194,13 @@ public class MultiConnectionNntpClient(ConnectionPool<INntpClient> connectionPoo
{
result = await command(connectionLock.Connection, OnConnectionReadyAgain).ConfigureAwait(false);
}
- catch (Exception e) when (e.TryGetInnerException(out UsenetArticleNotFoundException _))
+ catch (Exception e) when (e.TryGetCausingException(out UsenetArticleNotFoundException _))
{
LogException(() => connectionLock?.Dispose());
LogException(() => onConnectionReadyAgain?.Invoke(ArticleBodyResult.NotRetrieved));
throw;
}
- catch (Exception e) when (!e.TryGetInnerException(out UsenetArticleNotFoundException _))
+ catch (Exception e) when (!e.TryGetCausingException(out UsenetArticleNotFoundException _))
{
LogException(() => connectionLock?.Replace());
LogException(() => connectionLock?.Dispose());
diff --git a/backend/Extensions/ExceptionExtensions.cs b/backend/Extensions/ExceptionExtensions.cs
index 54e6d33d..adbccd2f 100644
--- a/backend/Extensions/ExceptionExtensions.cs
+++ b/backend/Extensions/ExceptionExtensions.cs
@@ -21,10 +21,10 @@ public static class ExceptionExtensions
return exception is TaskCanceledException or OperationCanceledException;
}
- public static bool TryGetInnerException<T>(this Exception exception, out T? exceptionType) where T : Exception
+ public static bool TryGetCausingException<T>(this Exception exception, out T? exceptionType) where T : Exception
{
ArgumentNullException.ThrowIfNull(exception);
- var current = exception.InnerException;
+ var current = exception;
while (current != null)
{
diff --git a/backend/Utils/RarUtil.cs b/backend/Utils/RarUtil.cs
index 718a06ee..bda722cf 100644
--- a/backend/Utils/RarUtil.cs
+++ b/backend/Utils/RarUtil.cs
@@ -67,7 +67,7 @@ public static class RarUtil
return headers;
}
- catch (Exception e) when (e.TryGetInnerException(out UsenetArticleNotFoundException missingArticleException))
+ catch (Exception e) when (e.TryGetCausingException(out UsenetArticleNotFoundException missingArticleException))
{
throw missingArticleException;
}