Zero-Config Setup
Add two lines of code and every unhandled exception returns a structured JSON response — no configuration required.
Transform unhandled exceptions into clean, structured JSON responses with minimal setup — just two lines of code to get started.
dotnet add package ErrorLens.ErrorHandlingvar builder = WebApplication.CreateBuilder(args);
builder.Services.AddErrorHandling();
var app = builder.Build();
app.UseErrorHandling();
app.Run();Any unhandled exception automatically becomes a structured JSON response:
{
"code": "USER_NOT_FOUND",
"message": "Could not find user with id 123"
}| Package | Target | NuGet |
|---|---|---|
ErrorLens.ErrorHandling | .NET 6 - 10 | |
ErrorLens.ErrorHandling.OpenApi | .NET 9+ | |
ErrorLens.ErrorHandling.Swashbuckle | .NET 6 - 8 | |
ErrorLens.ErrorHandling.FluentValidation | .NET 6 - 10 |