AugusteVN.Api.Exceptions 1.0.5

dotnet add package AugusteVN.Api.Exceptions --version 1.0.5
                    
NuGet\Install-Package AugusteVN.Api.Exceptions -Version 1.0.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AugusteVN.Api.Exceptions" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AugusteVN.Api.Exceptions" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="AugusteVN.Api.Exceptions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AugusteVN.Api.Exceptions --version 1.0.5
                    
#r "nuget: AugusteVN.Api.Exceptions, 1.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AugusteVN.Api.Exceptions@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AugusteVN.Api.Exceptions&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=AugusteVN.Api.Exceptions&version=1.0.5
                    
Install as a Cake Tool

Exceptions

Handle exceptions in server-side (HTTP) context.

Includes: GlobalExceptionHandler implementing the IExceptionHandler interface.

This will handle the following exception types out-of-the-box:

  • ValidationException (FluentValidation)
  • ForbiddenAccessException (AugusteVN.Features.Exceptions)
  • NotFoundException (AugusteVN.Features.Exceptions)
  • UnauthorizedAccessException
  • _ => HandleUnknownException

Or, you can use your own class by having it implement ICustomExceptionHandler.


Register Class Only

Default CustomExceptionHandler registration as scoped and implements ICustomExceptionHandler.

Use case: access the default Exception handling logic in your own middleware or filters. Used by: https://www.nuget.org/packages/AugusteVN.Api.EndpointFilters/

builder.Services.AddCustomExceptionHandler();

Usage Example

public class EndpointExceptionFilter (ICustomExceptionHandler exceptionHandler) : IEndpointFilter
{
    public async ValueTask<object?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next)
    {
        try
        {
            return await next(context);
        }
        catch (Exception e)
        {
            return exceptionHandler.Handle(e);
        }
    }
}

Register as Global Exception Handler

Registers the implementation class for ICustomExceptionHandler and as global handler a GlobalExceptionHandler for IExceptionHandler.

By default GlobalExceptionHandler will use CustomExceptionHandler but you can use your own implementation for ICustomExceptionHandler.

This includes the registration of requirement: .AddProblemDetails().

builder.Services.AddGlobalExceptionHandler();

// Or, with your handler class.
builder.Services.AddGlobalExceptionHandler<TCustomHandler>();

...
    
app.UseExceptionHandler();

Register as Middleware

An alternative approach, not using the IExceptionHandler is to simply register it as middleware.

builder.Services.AddGlobalExceptionHandlingMiddleware();
// Or, with your handler class.
builder.Services.AddGlobalExceptionHandlingMiddleware<TCustomHandler>();

...
    
app.UseMiddleware<GlobalExceptionHandlerMiddleware>();

Get the original source code: kiss-code.com

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on AugusteVN.Api.Exceptions:

Package Downloads
AugusteVN.Api.EndpointFilters

A collection of endpoint filters for a minimal API.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 92 3/23/2026
1.0.4 67 3/23/2026
1.0.3 89 3/23/2026

Return ProblemDetails instead of IResult.