From d214cb537156f291ffb87e07699670fcae3388f9 Mon Sep 17 00:00:00 2001 From: Marco Minerva Date: Thu, 15 Feb 2024 09:25:16 +0100 Subject: [PATCH] Move AddDefaultExceptionHandler method --- .../ExceptionHandlerExtensions.cs | 14 -------------- .../Extensions/ServiceCollectionExtensions.cs | 9 +++++++++ 2 files changed, 9 insertions(+), 14 deletions(-) delete mode 100644 src/TinyHelpers.AspNetCore/ExceptionHandlers/ExceptionHandlerExtensions.cs diff --git a/src/TinyHelpers.AspNetCore/ExceptionHandlers/ExceptionHandlerExtensions.cs b/src/TinyHelpers.AspNetCore/ExceptionHandlers/ExceptionHandlerExtensions.cs deleted file mode 100644 index d07a3df..0000000 --- a/src/TinyHelpers.AspNetCore/ExceptionHandlers/ExceptionHandlerExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; - -namespace TinyHelpers.AspNetCore.ExceptionHandlers; - -#if NET8_0_OR_GREATER -public static class ExceptionHandlerExtensions -{ - public static IServiceCollection AddDefaultExceptionHandler(this IServiceCollection services) - { - services.AddExceptionHandler(); - return services; - } -} -#endif diff --git a/src/TinyHelpers.AspNetCore/Extensions/ServiceCollectionExtensions.cs b/src/TinyHelpers.AspNetCore/Extensions/ServiceCollectionExtensions.cs index b5f2d6e..dc9dcfa 100644 --- a/src/TinyHelpers.AspNetCore/Extensions/ServiceCollectionExtensions.cs +++ b/src/TinyHelpers.AspNetCore/Extensions/ServiceCollectionExtensions.cs @@ -8,6 +8,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; +using TinyHelpers.AspNetCore.ExceptionHandlers; using TinyHelpers.AspNetCore.TypeConverters; namespace TinyHelpers.AspNetCore.Extensions; @@ -78,4 +79,12 @@ public static IServiceCollection AddDefaultProblemDetails(this IServiceCollectio return services; } #endif + +#if NET8_0_OR_GREATER + public static IServiceCollection AddDefaultExceptionHandler(this IServiceCollection services) + { + services.AddExceptionHandler(); + return services; + } +#endif } \ No newline at end of file