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.
9 lines
454 B
C#
9 lines
454 B
C#
using System.Net;
|
|
|
|
namespace DigitalData.Core.Exceptions.Middleware;
|
|
|
|
public record HttpExceptionMapping(Type ExceptionType, HttpStatusCode StatusCode, Func<Exception, string>? MessageFactory = null)
|
|
{
|
|
public static HttpExceptionMapping Create<TException>(HttpStatusCode statusCode, Func<Exception, string>? messageFactory = null) where TException : Exception
|
|
=> new HttpExceptionMapping(typeof(TException), statusCode, messageFactory);
|
|
}; |