aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-04-23 21:23:29 -0600
committercrobibero <cody@robibe.ro>2020-04-23 21:23:29 -0600
commit3c34d956088430da08bdd812c05d6a87c3bf9d25 (patch)
tree4b0f649de59a26fd87a07558e990f4c6379f8d7d
parentc6eebca335d09d6a6c627205e126448ab5441f37 (diff)
Address comments
-rw-r--r--Jellyfin.Server/Middleware/ExceptionMiddleware.cs36
1 files changed, 29 insertions, 7 deletions
diff --git a/Jellyfin.Server/Middleware/ExceptionMiddleware.cs b/Jellyfin.Server/Middleware/ExceptionMiddleware.cs
index ecc76594e..6ebe01503 100644
--- a/Jellyfin.Server/Middleware/ExceptionMiddleware.cs
+++ b/Jellyfin.Server/Middleware/ExceptionMiddleware.cs
@@ -1,8 +1,10 @@
using System;
using System.IO;
using System.Net.Mime;
+using System.Net.Sockets;
using System.Threading.Tasks;
using MediaBrowser.Common.Extensions;
+using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Net;
using Microsoft.AspNetCore.Http;
@@ -55,15 +57,35 @@ namespace Jellyfin.Server.Middleware
}
ex = GetActualException(ex);
- _logger.LogError(
- ex,
- "Error processing request: {ExceptionMessage}. URL {Method} {Url}. ",
- ex.Message,
- context.Request.Method,
- context.Request.Path);
+
+ bool ignoreStackTrace =
+ ex is SocketException
+ || ex is IOException
+ || ex is OperationCanceledException
+ || ex is SecurityException
+ || ex is AuthenticationException
+ || ex is FileNotFoundException;
+
+ if (ignoreStackTrace)
+ {
+ _logger.LogError(
+ "Error processing request: {ExceptionMessage}. URL {Method} {Url}.",
+ ex.Message.TrimEnd('.'),
+ context.Request.Method,
+ context.Request.Path);
+ }
+ else
+ {
+ _logger.LogError(
+ ex,
+ "Error processing request. URL {Method} {Url}.",
+ ex.Message.TrimEnd('.'),
+ context.Request.Method,
+ context.Request.Path);
+ }
+
context.Response.StatusCode = GetStatusCode(ex);
context.Response.ContentType = MediaTypeNames.Text.Plain;
-
var errorContent = NormalizeExceptionMessage(ex.Message);
await context.Response.WriteAsync(errorContent).ConfigureAwait(false);
}