Skip to content

Commit

Permalink
Merge pull request #72 from mayuki/hotfix/IgnoreExceptionOnAborted
Browse files Browse the repository at this point in the history
Skip Exception logging if the connection is aborted
  • Loading branch information
mayuki authored Nov 24, 2021
2 parents 7662369 + ac53159 commit 5e33a72
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Rin/Middlewares/RequestRecorderMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Connections;

namespace Rin.Middlewares
{
Expand Down Expand Up @@ -91,7 +92,13 @@ record = await PreprocessAsync(context, options, timelineRoot);
}
catch (Exception ex)
{
_logger.LogError(ex, "Unhandled Exception was thrown until post-processing");
var skipLogging = context.RequestAborted.IsCancellationRequested ||
(ex is IOException && ex.InnerException is ConnectionAbortedException);

if (!skipLogging)
{
_logger.LogError(ex, "Unhandled Exception was thrown until post-processing");
}
}
}
}
Expand Down

0 comments on commit 5e33a72

Please sign in to comment.