From 562f352243e48aa580cca058280d75cbe8210970 Mon Sep 17 00:00:00 2001 From: "m.tre" Date: Wed, 26 Jun 2024 15:10:39 +0500 Subject: [PATCH] fix Invoke_ShouldNotCatch_IgnoredUnhandledExceptions in UnhandledExceptionMiddlewareTests --- .../UnhandledExceptionMiddlewareTests.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Vostok.Applications.AspNetCore.Tests/MiddlewareTests/UnhandledExceptionMiddlewareTests.cs b/Vostok.Applications.AspNetCore.Tests/MiddlewareTests/UnhandledExceptionMiddlewareTests.cs index c9ac19f..3d06138 100644 --- a/Vostok.Applications.AspNetCore.Tests/MiddlewareTests/UnhandledExceptionMiddlewareTests.cs +++ b/Vostok.Applications.AspNetCore.Tests/MiddlewareTests/UnhandledExceptionMiddlewareTests.cs @@ -39,7 +39,7 @@ public async Task Invoke_ShouldCatch_UnhandledExceptions() public async Task Invoke_ShouldNotCatch_IgnoredUnhandledExceptions() { var result = await Client.GetAsync("canceled-bad-http-exception"); - + result.Response.Code.Should().Be(CanceledResponseCode); } #endif @@ -55,11 +55,15 @@ protected override void SetupGlobal(IVostokAspNetCoreWebApplicationBuilder build builder.SetupUnhandledExceptions(SetupUnhandledExceptions); } #endif - + #if ASPNTCORE_HOSTING protected override void SetupGlobal(Microsoft.AspNetCore.Builder.WebApplicationBuilder builder, Vostok.Hosting.AspNetCore.Web.Configuration.IVostokMiddlewaresConfigurator middlewaresConfigurator) { - middlewaresConfigurator.ConfigureUnhandledExceptions(s => s.ErrorResponseCode = ResponseCode); + middlewaresConfigurator.ConfigureUnhandledExceptions(s => + { + s.ErrorResponseCode = ResponseCode; + s.ExceptionsToIgnore.Add(typeof(BadHttpRequestException)); + }); } #endif