14 Commits

Author SHA1 Message Date
048ba35804 remove ReadQuery 2025-08-21 18:19:16 +02:00
56cb3e247f fix(GlobalExceptionHandlerMiddleware): add await 2025-07-30 17:00:03 +02:00
Developer 02
87e4c1414e Enhance ConfigureGlobalExceptionHandler method
Updated the `ConfigureGlobalExceptionHandler` method in the `DependencyInjection` class to include two optional parameters: `options` (nullable) and `addDefaultHandlers` (defaulting to true). The method now initializes `options` to a default action if null and adds default exception handlers when `addDefaultHandlers` is true, improving flexibility and usability.
2025-05-19 16:45:40 +02:00
Developer 02
fd8e976e1e Refactor HttpExceptionHandler to use properties
Changed DefaultBadRequest, DefaultNotFound, and Default
from readonly fields to properties for lazy evaluation,
enhancing performance and flexibility while maintaining
the same functionality.
2025-05-19 16:18:05 +02:00
Developer 02
2c393701e4 Add NuGet package metadata and asset inclusion
Updated `DigitalData.Core.Exceptions.Middleware.csproj` to include essential NuGet package metadata such as `PackageId`, `Authors`, `Description`, and versioning information. Added an `ItemGroup` for the `core_icon.png` asset to ensure it is packed with the NuGet package. Retained existing framework-specific references for `Microsoft.Extensions.Options` for `net7.0` and `net8.0`.
2025-05-19 16:09:45 +02:00
Developer 02
b8995da5ea Refactor global exception handling middleware
Updated `GlobalExceptionHandlerMiddleware.cs` to include
necessary using directives for logging and options handling.
Removed the `HandleExceptionAsync` method and replaced it
with a more extensible approach using a dictionary of
handlers for different exception types. Added logging for
unhandled exceptions to ensure proper error tracking.
2025-05-19 15:21:11 +02:00
Developer 02
14013bc7b7 Add default handlers to HttpExceptionHandler
Introduce static methods for creating HttpExceptionHandler instances for specific exceptions. Define default message factory and handlers for common HTTP status codes, including a generic handler that returns a JSON response for internal server errors.
2025-05-19 15:06:24 +02:00
Developer 02
f586e9eb2f Refactor exception handling to use HttpExceptionHandler
Updated GlobalExceptionHandlerOptions to replace HttpExceptionMapping with HttpExceptionHandler. Removed HttpExceptionMapping class and introduced HttpExceptionHandler for managing exceptions in HTTP requests. Added methods for creating specific exception handlers and default handlers for common exceptions, with JSON serialization for error messages.
2025-05-19 15:01:50 +02:00
Developer 02
ce786a6d42 Update package references in project file
Updated `DigitalData.Core.Exceptions.Middleware.csproj` to include specific `Microsoft.Extensions.Options` package references for target frameworks net7.0, net8.0, and net9.0. Removed the previous single `<ItemGroup>` and added three new `<ItemGroup>` entries with the corresponding package versions.
2025-05-19 14:41:46 +02:00
Developer 02
97695fb0b0 Add dependency injection for global exception handler
Introduce methods in DependencyInjection.cs for configuring
and using a global exception handler. Update the project file
to include a reference to Microsoft.Extensions.Options.
Modify GlobalExceptionHandlerMiddleware to accept
IOptions<GlobalExceptionHandlerOptions> for enhanced
configuration through dependency injection.
2025-05-19 14:38:49 +02:00
Developer 02
cb7b69a0a2 Refactor GlobalExceptionHandlerOptions for better access
Updated the accessibility of the RegisteredMappings field to internal and introduced a DefaultMapping property. Modified the Add method to support setting a mapping as default, with adjusted logic for adding mappings.
2025-05-19 14:30:50 +02:00
Developer 02
b38422256c Enhance HttpExceptionMapping with logging and defaults
Added optional 'Log' property to HttpExceptionMapping for
specifying logging behavior. Introduced static readonly
properties for default mappings of BadRequestException and
NotFoundException using a default message factory.
2025-05-19 14:24:10 +02:00
Developer 02
9b29a49ad6 Refactor exception handling with new mapping system
Updated `GlobalExceptionHandlerOptions` to use a new `_registeredMappings` dictionary for `HttpExceptionMapping` objects, enhancing flexibility in mapping exceptions to HTTP responses. Renamed `RegisterException` to `Add` to reflect its new functionality. Removed the `HttpResponse` record definition and introduced a new `HttpExceptionMapping` record, which includes a static `Create` method for easier instantiation of mappings.
2025-05-19 14:15:38 +02:00
Developer 02
83ba492b37 Add global exception handling middleware
Introduces `GlobalExceptionHandlerMiddleware` for managing exceptions in the request pipeline, logging them, and returning JSON error responses. A new project, `DigitalData.Core.Exceptions.Middleware`, is created to house this middleware and related classes. The `GlobalExceptionHandlerOptions` class allows for custom exception registration with specific HTTP status codes, while a new `HttpResponse` record encapsulates status codes and messages for structured responses. The middleware is registered in the `DependencyInjection` class for easy integration.
2025-05-19 13:27:37 +02:00