DigitalData.Core/DigitalData.Core.Exceptions.Middleware/GlobalExceptionHandlerOptions.cs
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

17 lines
540 B
C#

namespace DigitalData.Core.Exceptions.Middleware;
public class GlobalExceptionHandlerOptions
{
internal readonly Dictionary<Type, HttpExceptionMapping> RegisteredMappings = new();
internal HttpExceptionMapping? DefaultMapping { get; private set; }
public GlobalExceptionHandlerOptions Add(HttpExceptionMapping mapping, bool setAsDefault = false)
{
if (setAsDefault)
DefaultMapping = mapping;
else
RegisteredMappings[mapping.ExceptionType] = mapping;
return this;
}
}