Skip to content

Commit

Permalink
No longer rely on HttpContext.AddError to forward Web API exceptions …
Browse files Browse the repository at this point in the history
…to SerilogWeb module

Instead rely on ad-hoc extension method that stores it temporarily in HttpContext

Related to serilog-web#16 and serilog-web#3
  • Loading branch information
tsimbalar committed Feb 28, 2019
1 parent 8de367c commit 3615db6
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System.Web;
using System.Web.Http.ExceptionHandling;
using SerilogWeb.Classic.Extensions;

namespace SerilogWeb.Classic.WebApi
{
public class WebApiExceptionLogger : ExceptionLogger
{
public override void Log(ExceptionLoggerContext context)
{
HttpContext.Current.AddError(context.Exception);
if (context.Exception != null)
{
HttpContext.Current.AddSerilogWebError(context.Exception);
}
}
}
}

0 comments on commit 3615db6

Please sign in to comment.