Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
Added friendlier logging for DavItem read errors.
nzbdav-devf9704d94a161
diff --git a/backend/Middlewares/ExceptionMiddleware.cs b/backend/Middlewares/ExceptionMiddleware.csindex 7a7a0474..1cc7b8af 100644--- a/backend/Middlewares/ExceptionMiddleware.cs+++ b/backend/Middlewares/ExceptionMiddleware.cs@@ -47,6 +47,17 @@ public class ExceptionMiddleware(RequestDelegate next)var seekPosition = context.Request.GetRange()?.Start?.ToString() ?? "unknown";Log.Error($"File `{filePath}` could not seek to byte position: {seekPosition}");}+ catch (Exception e) when (IsDavItemRequest(context))+ {+ if (!context.Response.HasStarted)+ {+ context.Response.Clear();+ context.Response.StatusCode = 500;+ }++ var filePath = GetRequestFilePath(context);+ Log.Error($"File `{filePath}` could not be read due to unhandled {e.GetType()}: {e.Message}");+ }}private static string GetRequestFilePath(HttpContext context)@@ -55,4 +66,9 @@ public class ExceptionMiddleware(RequestDelegate next)? davItem.Path: context.Request.Path;}++ private static bool IsDavItemRequest(HttpContext context)+ {+ return context.Items["DavItem"] is DavItem;+ }}\ No newline at end of file