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.
12 lines
360 B
C#
12 lines
360 B
C#
namespace DigitalData.Core.Exceptions.Middleware;
|
|
|
|
public class GlobalExceptionHandlerOptions
|
|
{
|
|
private readonly Dictionary<Type, HttpExceptionMapping> _registeredMappings = new();
|
|
|
|
public GlobalExceptionHandlerOptions Add(HttpExceptionMapping mapping)
|
|
{
|
|
_registeredMappings[mapping.ExceptionType] = mapping;
|
|
return this;
|
|
}
|
|
} |