fix(GlobalExceptionHandlerMiddleware): add await
This commit is contained in:
parent
0554cbf7bc
commit
56cb3e247f
@ -38,6 +38,10 @@
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.5" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DigitalData.Core.Exceptions\DigitalData.Core.Exceptions.csproj" />
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user