NTT.ExceptionHandler
1.0.2
dotnet add package NTT.ExceptionHandler --version 1.0.2
NuGet\Install-Package NTT.ExceptionHandler -Version 1.0.2
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="NTT.ExceptionHandler" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NTT.ExceptionHandler --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NTT.ExceptionHandler, 1.0.2"
#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.
// Install NTT.ExceptionHandler as a Cake Addin #addin nuget:?package=NTT.ExceptionHandler&version=1.0.2 // Install NTT.ExceptionHandler as a Cake Tool #tool nuget:?package=NTT.ExceptionHandler&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
This is a testing package for Customized Exception Handling.
Requires .NET 8.0 or higher.
Usage
builder.Services.AddNTTExceptionHandler();
app.UseNTTExceptionHandler();
throw new BusinessException("This is a test business exception.");
Result
{
"StatusCode": 400,
"Result": {
"TraceId": "20fd343d-b08e-4545-8547-ee994fda9e4d",
"ExceptionType": "Business.Exception",
"Message": "This is a test business exception."
}
}
Notes for Serilog
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.Enrich.WithProperty("Application", "YOURAPPLICATIONNAME")
.Enrich.WithProperty("Environment", Environment.GetEnvironmentVariables())
.Filter.ByIncludingOnly( e => e.Exception is not null)
.Filter.ByExcluding(e=>e.Properties.ContainsKey("EventId"))
.WriteTo.AzureCosmosDB(endpointUri: new Uri("cosmos-uri"),
"auth-key"
)
.WriteTo.Console()
.CreateLogger();
builder.Host.UseSerilog();
.Filter.ByExcluding(e=>e.Properties.ContainsKey("EventId"))
If you do not add this filter, Microsoft Diagnostics will log a duplicated exception.
.Filter.ByIncludingOnly( e => e.Exception is not null)
If you do not add this filter, Serilog will be logging everything about the application.
Make sure to make some research about Serilog before using it.
Notes for Form-Data
If you want to log form-data payload. You should handle anti-forgery token.
Either disable for the particular action or add the token to the form-data.
Incoming Features
- AI integration for translating exception messages.
Product | Versions 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.OpenApi (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.2 | 102 | 3/12/2024 |