BitzArt.ApiExceptions.OpenTelemetry 1.22.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package BitzArt.ApiExceptions.OpenTelemetry --version 1.22.0
NuGet\Install-Package BitzArt.ApiExceptions.OpenTelemetry -Version 1.22.0
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="BitzArt.ApiExceptions.OpenTelemetry" Version="1.22.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BitzArt.ApiExceptions.OpenTelemetry --version 1.22.0
#r "nuget: BitzArt.ApiExceptions.OpenTelemetry, 1.22.0"
#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 BitzArt.ApiExceptions.OpenTelemetry as a Cake Addin
#addin nuget:?package=BitzArt.ApiExceptions.OpenTelemetry&version=1.22.0

// Install BitzArt.ApiExceptions.OpenTelemetry as a Cake Tool
#tool nuget:?package=BitzArt.ApiExceptions.OpenTelemetry&version=1.22.0

Tests

General

This library defines ApiExceptions that you can throw in your .Net applications.

Use with Asp.Net Core

💡 You can always refer to this sample project for guidance.

Setup:

Add the nuget package:

dotnet add package BitzArt.ApiExceptions.AspNetCore

Add this line to your Program.cs when configuring services:

builder.Services.AddApiExceptionHandler();

Add this line to your Program.cs when configuring the request pipeline:

// This line should go before any other middleware that might throw exceptions
app.UseApiExceptionHandler();

Usage:

Then, anywhere in your code, you can throw exceptions like:

throw ApiException.BadRequest("your error message");

This will stop any further execution and generate an http response with an appropriate http status code.

The package handles both ApiExceptions as well as regular Exceptions. If the exception is of type ApiException, it will generate a response with the appropriate status code and message. If the exception is of type Exception, the status code will be 500.

💡 These responses are aligned with RFC7807: Problem Details for HTTP APIs.

Use outside of Asp.Net Core

To use ApiExceptions in your applications, add this nuget package to your project:

dotnet add package BitzArt.ApiExceptions

This will allow you to create and throw ApiExceptions, and you can then handle them as you see fit.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BitzArt.ApiExceptions.OpenTelemetry:

Package Downloads
BitzArt.OpenTelemetry.BoilerPlate The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Some boilerplate code for OpenTelemetry

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.22.0 88 4/2/2024
1.21.2 70 4/2/2024
1.21.1 991 3/18/2024
1.21.0 90 3/18/2024
1.20.0 201 2/27/2024
1.19.0 433 1/30/2024
1.18.2 206 9/5/2023
1.18.1 97 9/5/2023
1.18.0 94 9/5/2023
1.17.1 97 8/18/2023
1.17.0 126 8/18/2023
1.16.0 123 8/14/2023
1.15.0 104 8/14/2023
1.14.1 125 8/10/2023
1.14.0 125 8/10/2023
1.13.0 121 8/10/2023