1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-02 23:41:21 +01:00

fix billing problems

This commit is contained in:
Kyle Spearrin 2017-09-08 11:41:38 -04:00
parent 5a53a2c218
commit a17003b302
2 changed files with 27 additions and 1 deletions

View File

@ -10,6 +10,7 @@ using Bit.Core.Utilities;
using Serilog.Events;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Bit.Billing.Utilities;
namespace Bit.Billing
{
@ -52,7 +53,10 @@ namespace Bit.Billing
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
// Mvc
services.AddMvc();
services.AddMvc(config =>
{
config.Filters.Add(new ExceptionHandlerFilterAttribute());
});
}
public void Configure(

View File

@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Bit.Billing.Utilities
{
public class ExceptionHandlerFilterAttribute : ExceptionFilterAttribute
{
public override void OnException(ExceptionContext context)
{
var exception = context.Exception;
if(exception == null)
{
// Should never happen.
return;
}
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<ExceptionHandlerFilterAttribute>>();
logger.LogError(0, exception, exception.Message);
}
}
}