This is a .NET Core library for global exception handling in your application.
Nuget - Nummy.ExceptionHandler
or install the package via NuGet Package Manager Console:
Install-Package Nummy.ExceptionHandler
In your Program.cs
file add the following line:
using Nummy.ExceptionHandler.Extensions;
using Nummy.ExceptionHandler.Models;
// .. other configurations
builder.Services.AddNummyExceptionHandler(options =>
{
// if false, the app throws exceptions as a normal
options.HandleException = true;
// set your response object and status code
options.Response = new { message = "An error occurred" };
options.ResponseStatusCode = HttpStatusCode.BadRequest;
options.DsnUrl = "your-nummy-dsn-url"
});
// .. other configurations
var app = builder.Build();
var app = builder.Build();
// .. other configurations
app.UseNummyExceptionHandler();
// .. other middleware
Attetion: if you are using Nummy.HttpLogger, make sure to first register NummyHttpLogger and then NummyExceptionHandler.
3. Now, your application is set up to handle unhandled exceptions globally using the Nummy Exception Handler.
This library is licensed under the MIT License.