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.
17 lines
540 B
C#
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;
|
|
}
|
|
} |