Skip to content

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

C#

Log DavItem path instead of request path on errors.

nzbdav-dev6a03acd42cd5
diff --git a/backend/Middlewares/ExceptionMiddleware.cs b/backend/Middlewares/ExceptionMiddleware.cs
index 1939f2a0..7a7a0474 100644
--- a/backend/Middlewares/ExceptionMiddleware.cs
+++ b/backend/Middlewares/ExceptionMiddleware.cs
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Http;
using NWebDav.Server.Helpers;
+using NzbWebDAV.Database.Models;
using NzbWebDAV.Exceptions;
using Serilog;
@@ -31,7 +32,8 @@ public class ExceptionMiddleware(RequestDelegate next)
context.Response.StatusCode = 404;
}
- Log.Warning($"File `{context.Request.Path}` has missing articles: {e.Message}");
+ var filePath = GetRequestFilePath(context);
+ Log.Error($"File `{filePath}` has missing articles: {e.Message}");
}
catch (SeekPositionNotFoundException)
{
@@ -41,8 +43,16 @@ public class ExceptionMiddleware(RequestDelegate next)
context.Response.StatusCode = 404;
}
+ var filePath = GetRequestFilePath(context);
var seekPosition = context.Request.GetRange()?.Start?.ToString() ?? "unknown";
- Log.Warning($"File `{context.Request.Path}` could not seek to byte position: {seekPosition}");
+ Log.Error($"File `{filePath}` could not seek to byte position: {seekPosition}");
}
}
+
+ private static string GetRequestFilePath(HttpContext context)
+ {
+ return context.Items["DavItem"] is DavItem davItem
+ ? davItem.Path
+ : context.Request.Path;
+ }
}
\ No newline at end of file