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.
This commit is contained in:
@@ -2,11 +2,16 @@
|
|||||||
|
|
||||||
public class GlobalExceptionHandlerOptions
|
public class GlobalExceptionHandlerOptions
|
||||||
{
|
{
|
||||||
private readonly Dictionary<Type, HttpExceptionMapping> _registeredMappings = new();
|
internal readonly Dictionary<Type, HttpExceptionMapping> RegisteredMappings = new();
|
||||||
|
|
||||||
public GlobalExceptionHandlerOptions Add(HttpExceptionMapping mapping)
|
internal HttpExceptionMapping? DefaultMapping { get; private set; }
|
||||||
|
|
||||||
|
public GlobalExceptionHandlerOptions Add(HttpExceptionMapping mapping, bool setAsDefault = false)
|
||||||
{
|
{
|
||||||
_registeredMappings[mapping.ExceptionType] = mapping;
|
if (setAsDefault)
|
||||||
|
DefaultMapping = mapping;
|
||||||
|
else
|
||||||
|
RegisteredMappings[mapping.ExceptionType] = mapping;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user