Skip to content

Commit

Permalink
Logging exception fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Rose committed Mar 22, 2023
1 parent bb7bf84 commit bf22711
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Redbridge.WebApi/Filters/UnhandledExceptionLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellat
_logger.LogInformation("Logging (only) unhandled exceptions...");

if (context.Exception != null)
_logger.LogError(context.Exception.Message, context.Exception);
_logger.LogError(context.Exception, context.Exception.Message);

return Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Net.Http;
using System.Web.Http.Filters;
using Microsoft.Extensions.Logging;
using Redbridge.Diagnostics;
using Redbridge.Exceptions;

namespace Redbridge.WebApi.Filters
Expand All @@ -20,9 +19,7 @@ public override void OnException(HttpActionExecutedContext actionExecutedContext
{
_logger.LogInformation("Checking exception for user not authorized exception filtering....");

var exception = actionExecutedContext.Exception as UserNotAuthorizedException;

if (exception != null)
if (actionExecutedContext.Exception is UserNotAuthorizedException exception)
{
var response = new HttpResponseMessage(HttpStatusCode.Forbidden)
{
Expand Down

0 comments on commit bf22711

Please sign in to comment.