mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Address comments
This commit is contained in:
parent
c6eebca335
commit
3c34d95608
@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
|
using System.Net.Sockets;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
|
using MediaBrowser.Controller.Authentication;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Net;
|
using MediaBrowser.Controller.Net;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
@ -55,15 +57,35 @@ namespace Jellyfin.Server.Middleware
|
|||||||
}
|
}
|
||||||
|
|
||||||
ex = GetActualException(ex);
|
ex = GetActualException(ex);
|
||||||
_logger.LogError(
|
|
||||||
ex,
|
bool ignoreStackTrace =
|
||||||
"Error processing request: {ExceptionMessage}. URL {Method} {Url}. ",
|
ex is SocketException
|
||||||
ex.Message,
|
|| ex is IOException
|
||||||
context.Request.Method,
|
|| ex is OperationCanceledException
|
||||||
context.Request.Path);
|
|| 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.StatusCode = GetStatusCode(ex);
|
||||||
context.Response.ContentType = MediaTypeNames.Text.Plain;
|
context.Response.ContentType = MediaTypeNames.Text.Plain;
|
||||||
|
|
||||||
var errorContent = NormalizeExceptionMessage(ex.Message);
|
var errorContent = NormalizeExceptionMessage(ex.Message);
|
||||||
await context.Response.WriteAsync(errorContent).ConfigureAwait(false);
|
await context.Response.WriteAsync(errorContent).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user