Pitasoft.Error
5.0.1
See the version list below for details.
dotnet add package Pitasoft.Error --version 5.0.1
NuGet\Install-Package Pitasoft.Error -Version 5.0.1
<PackageReference Include="Pitasoft.Error" Version="5.0.1" />
<PackageVersion Include="Pitasoft.Error" Version="5.0.1" />
<PackageReference Include="Pitasoft.Error" />
paket add Pitasoft.Error --version 5.0.1
#r "nuget: Pitasoft.Error, 5.0.1"
#:package Pitasoft.Error@5.0.1
#addin nuget:?package=Pitasoft.Error&version=5.0.1
#tool nuget:?package=Pitasoft.Error&version=5.0.1
Pitasoft.Error
<a name="english"></a>
English
Pitasoft.Error is a class library designed to facilitate the handling and management of error collections in .NET applications. It allows grouping errors by property, handling change notifications, and serializing/deserializing error collections to/from JSON.
Key Features
- ErrorCollection: A robust collection for storing errors associated with property names.
- Notifications: Support for events when the error collection changes.
- JSON Serialization: Built-in extensions to convert error collections to JSON and vice versa.
- Multi-target Support: Compatible with .NET 8.0, .NET 9.0, and .NET 10.0.
Installation
You can install this package via NuGet:
dotnet add package Pitasoft.Error
Basic Usage
Creating an Error Collection and Adding Errors
using Pitasoft.Error;
var errors = new ErrorCollection();
errors.Add("Name", "The name is required.");
errors.Add("Email", "The email format is invalid.");
if (errors.AnyError())
{
// Handle errors
}
Using Static Creation Methods
var errors = ErrorCollection.Create("General", "An unexpected error has occurred.");
JSON Serialization
using Pitasoft.Error.Extensions;
string json = errors.ToJson();
Deserialization from JSON
string json = "{\"name\":[\"Error 1\"]}";
var errors = json.ToErrorCollection();
Event Notifications
You can subscribe to changes in the error collection:
var errors = new ErrorCollection();
errors.ErrorsChanged += (sender, e) =>
{
Console.WriteLine($"Property '{e.PropertyName}' was updated. Action: {e.Action}");
};
errors.Add("Username", "Already exists.");
Exception Handling
Easily convert exceptions into error collections:
try
{
// Some code that throws
}
catch (Exception ex)
{
var errors = ErrorCollection.Create(ex, deep: true);
// All inner exceptions are now captured in the collection
}
License
This project is licensed under the terms specified in the License.txt file.
Author
Sebastián Martínez Pérez - Pitasoft, S.L.
<a name="español"></a>
Español
Pitasoft.Error es una biblioteca de clases diseñada para facilitar el manejo y la gestión de colecciones de errores en aplicaciones .NET. Permite agrupar errores por propiedad, manejar notificaciones de cambios y serializar/deserializar colecciones de errores a JSON.
Características principales
- ErrorCollection: Una colección robusta para almacenar errores asociados a nombres de propiedades.
- Notificaciones: Soporte para eventos cuando la colección de errores cambia.
- Serialización JSON: Extensiones integradas para convertir colecciones de errores a JSON y viceversa.
- Soporte Multi-target: Compatible con .NET 8.0, .NET 9.0 y .NET 10.0.
Instalación
Puedes instalar este paquete a través de NuGet:
dotnet add package Pitasoft.Error
Uso básico
Crear una colección de errores y añadir errores
using Pitasoft.Error;
var errors = new ErrorCollection();
errors.Add("Nombre", "El nombre es obligatorio.");
errors.Add("Email", "El formato del email no es válido.");
if (errors.AnyError())
{
// Manejar errores
}
Uso de métodos estáticos de creación
var errors = ErrorCollection.Create("General", "Ha ocurrido un error inesperado.");
Serialización a JSON
using Pitasoft.Error.Extensions;
string json = errors.ToJson();
Deserialización desde JSON
string json = "{\"nombre\":[\"Error 1\"]}";
var errors = json.ToErrorCollection();
Notificaciones de Eventos
Puedes suscribirte a los cambios en la colección de errores:
var errors = new ErrorCollection();
errors.ErrorsChanged += (sender, e) =>
{
Console.WriteLine($"La propiedad '{e.PropertyName}' ha sido actualizada. Acción: {e.Action}");
};
errors.Add("Usuario", "Ya existe.");
Manejo de Excepciones
Convierte fácilmente excepciones en colecciones de errores:
try
{
// Código que lanza una excepción
}
catch (Exception ex)
{
var errors = ErrorCollection.Create(ex, deep: true);
// Todas las excepciones internas se capturan ahora en la colección
}
Licencia
Este proyecto está bajo la licencia especificada en el archivo License.txt.
Autor
Sebastián Martínez Pérez - Pitasoft, S.L.
| 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. 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 is compatible. 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. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Pitasoft.Error:
| Package | Downloads |
|---|---|
|
Pitasoft.Result
.NET library designed to standardize responses from REST services and internal application layers. It provides a robust set of classes to wrap data, status codes, and error collections, facilitating a unified communication contract between APIs, services, and clients. |
|
|
Pitasoft.Validation
A flexible and high-performance C# validation library designed to validate objects using multiple strategies, including Data Annotations, custom rules, and a fluent API. |
|
|
Pitasoft.Web
Librerias basicas de aplicaciones web |
|
|
Pitasoft.AspNetCore
Librerias basicas de aplicaciones web |
|
|
Pitasoft.Blazor.Validation
Blazor components for data validation in forms. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.3.14 | 698 | 3/23/2026 |
| 5.3.13 | 136 | 3/23/2026 |
| 5.3.12 | 119 | 3/23/2026 |
| 5.3.11 | 150 | 3/22/2026 |
| 5.3.10 | 123 | 3/22/2026 |
| 5.3.9 | 126 | 3/22/2026 |
| 5.3.8 | 199 | 3/20/2026 |
| 5.3.7 | 244 | 3/13/2026 |
| 5.3.6 | 201 | 3/10/2026 |
| 5.3.5 | 131 | 3/10/2026 |
| 5.3.4 | 127 | 3/10/2026 |
| 5.3.3 | 128 | 3/9/2026 |
| 5.3.2 | 329 | 3/2/2026 |
| 5.3.1 | 264 | 2/24/2026 |
| 5.2.2 | 197 | 2/23/2026 |
| 5.2.1 | 128 | 2/22/2026 |
| 5.1.1 | 136 | 2/17/2026 |
| 5.0.3 | 185 | 2/4/2026 |
| 5.0.2 | 197 | 1/26/2026 |
| 5.0.1 | 140 | 1/26/2026 |