namespace DigitalData.Core.Exceptions.Middleware;

public class GlobalExceptionHandlerOptions
{
    internal readonly Dictionary<Type, HttpExceptionHandler> Handlers = new();

    internal HttpExceptionHandler? DefaultHandler { get; private set; }

    public GlobalExceptionHandlerOptions Add(HttpExceptionHandler handler, bool setAsDefault = false)
    {
        if (setAsDefault)
            DefaultHandler = handler;
        else
            Handlers[handler.ExceptionType] = handler;
        return this;
    }
}