Skip to content

solarvoyager/Nummy.ExceptionHandler

Repository files navigation

Nummy Global Exception & Logging Handling, Monitoring package for .NET Core

NuGet Version NuGet Downloads License

Overview

This is a .NET Core library for global exception handling in your application.

Installation

Nuget - Nummy.ExceptionHandler

or install the package via NuGet Package Manager Console:

Install-Package Nummy.ExceptionHandler

Getting Started

1. Run Nummy on your Docker and get DSN url of your local instance

Here is tutorial

2. Configure your application

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.

License

This library is licensed under the MIT License.

About

Global Exception handling package for .net core apps

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages