MgcFramework.Exceptions 9.1.0

dotnet add package MgcFramework.Exceptions --version 9.1.0
                    
NuGet\Install-Package MgcFramework.Exceptions -Version 9.1.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="MgcFramework.Exceptions" Version="9.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MgcFramework.Exceptions" Version="9.1.0" />
                    
Directory.Packages.props
<PackageReference Include="MgcFramework.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 MgcFramework.Exceptions --version 9.1.0
                    
#r "nuget: MgcFramework.Exceptions, 9.1.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.
#:package MgcFramework.Exceptions@9.1.0
                    
#: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=MgcFramework.Exceptions&version=9.1.0
                    
Install as a Cake Addin
#tool nuget:?package=MgcFramework.Exceptions&version=9.1.0
                    
Install as a Cake Tool

MgcFramework Exceptions

MgcFramework Exceptions is a .NET class library that provides tools for handling exceptions in a centralized manner using middleware.

Project Structure

Definitions/
	ExceptionsDefinition.cs
Dtos/
	BadRequestException.cs
	BusinessException.cs
	InternalServerErrorException.cs
	NotFoundException.cs
	UnprocessableEntityException.cs
Middleware/
	ErrorDetails.cs
	ExceptionMiddleware.cs
	ExceptionMiddlewareExtension.cs

Getting Started

Prerequisites

  • .NET 9.0 SDK or later

Installation

To install the project dependencies, run the following command:

dotnet restore

Building the Project

To build the project, run the following command in the root directory:

dotnet build

Usage

ExceptionMiddleware

The ExceptionMiddleware class provides a centralized way to handle exceptions in your application.

Example
using MgcFramework.Exceptions.Middleware;
using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.UseExceptionMiddleware();

ErrorDetails

The ErrorDetails class represents the details of an error, including the error type and a list of error messages.

Example
var errorDetails = new ErrorDetails
{
    ErrorType = "BadRequest",
    Errors = new List<string> { "Invalid input data" }
};

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Author

Mtro. Christian Gómez Simón - [ChriisTKD]

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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

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
9.1.0 116 2/7/2025
9.0.0 115 1/24/2025