Pargoon.Exceptions
1.0.1
See the version list below for details.
dotnet add package Pargoon.Exceptions --version 1.0.1
NuGet\Install-Package Pargoon.Exceptions -Version 1.0.1
<PackageReference Include="Pargoon.Exceptions" Version="1.0.1" />
paket add Pargoon.Exceptions --version 1.0.1
#r "nuget: Pargoon.Exceptions, 1.0.1"
// Install Pargoon.Exceptions as a Cake Addin #addin nuget:?package=Pargoon.Exceptions&version=1.0.1 // Install Pargoon.Exceptions as a Cake Tool #tool nuget:?package=Pargoon.Exceptions&version=1.0.1
Pargoon.Exceptions
Pargoon.Exceptions is a .NET Standard library designed to simplify exception handling in .NET applications. It provides a set of classes to help manage errors in a consistent and structured manner.
Features
- AppError: A simple class to encapsulate error details such as HTTP status code, error code, and error message.
- AppException: A custom exception class that extends the base
Exception
class, allowing for more detailed error information including HTTP status codes and custom error codes.
Installation
To install this library, you can use the following command in the NuGet Package Manager:
Install-Package Pargoon.Exceptions
Or add it to your project file:
<PackageReference Include="Pargoon.Exceptions" Version="1.0.0" />
Usage
AppError Class
The AppError
class is designed to hold error details such as StatusCode
, ErrorCode
, and ErrorMessage
. You can use this class to define the error that you want to handle.
var error = new AppError
{
StatusCode = HttpStatusCode.BadRequest,
ErrorCode = "400",
ErrorMessage = "Invalid request data."
};
AppException Class
The AppException
class is a custom exception that can be thrown in your application to handle errors more effectively. This class allows you to pass error details when an exception occurs.
throw new AppException(HttpStatusCode.BadRequest, "Invalid request data.", "400");
Alternatively, you can create an AppException
from an AppError
object:
throw new AppException(error);
Example
Here is a simple example of how to use the Pargoon.Exceptions library:
try
{
// Some code that may throw an exception
throw new AppException(HttpStatusCode.NotFound, "Resource not found", "404");
}
catch (AppException ex)
{
Console.WriteLine($"Error: {ex.ErrorCode}, Status: {ex.Status}, Message: {ex.Message}");
}
Contributing
Contributions are welcome! Please open an issue or submit a pull request if you would like to contribute to this project.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Pargoon.Core (>= 1.2.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Pargoon.Exceptions:
Package | Downloads |
---|---|
Noyan.ShadMessage.ApiContracts
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.