fix(GlobalExceptionHandlerMiddleware): add await

This commit is contained in:
2025-07-30 17:00:03 +02:00
parent 0554cbf7bc
commit 56cb3e247f
2 changed files with 7 additions and 3 deletions

View File

@@ -42,11 +42,11 @@ public class GlobalExceptionHandlerMiddleware
}
catch (Exception ex)
{
if(ex.GetType() == typeof(Exception))
_options?.DefaultHandler?.HandleExceptionAsync.Invoke(context, ex, _logger);
if(ex.GetType() == typeof(Exception) && _options?.DefaultHandler is not null)
await _options.DefaultHandler.HandleExceptionAsync(context, ex, _logger);
if (_options?.Handlers.TryGetValue(ex.GetType(), out var handler) ?? false)
handler?.HandleExceptionAsync.Invoke(context, ex, _logger);
await handler.HandleExceptionAsync(context, ex, _logger);
}
}
}