Fermat.Domain.Exceptions
0.0.1
dotnet add package Fermat.Domain.Exceptions --version 0.0.1
NuGet\Install-Package Fermat.Domain.Exceptions -Version 0.0.1
<PackageReference Include="Fermat.Domain.Exceptions" Version="0.0.1" />
<PackageVersion Include="Fermat.Domain.Exceptions" Version="0.0.1" />
<PackageReference Include="Fermat.Domain.Exceptions" />
paket add Fermat.Domain.Exceptions --version 0.0.1
#r "nuget: Fermat.Domain.Exceptions, 0.0.1"
#:package Fermat.Domain.Exceptions@0.0.1
#addin nuget:?package=Fermat.Domain.Exceptions&version=0.0.1
#tool nuget:?package=Fermat.Domain.Exceptions&version=0.0.1
Fermat.Domain.Exceptions
Fermat.Exceptions is a library that provides a comprehensive exception handling system for .NET applications. It includes predefined exception types and interfaces for standardized error handling across your application.
Features
- Predefined exception types for common scenarios
- Standardized exception interfaces
- HTTP status code mapping
- Validation error handling
- Business rule violation handling
- Entity not found handling
- User-friendly error messages
- Correlation ID support
Installation
dotnet add package Fermat.Domain.Exceptions
Content
Exception Types
Base Exception
AppException
: Base exception class with common properties and behaviors- Error code
- Error details
- Timestamp
- Correlation ID
Domain Exceptions
AppEntityNotFoundException
: Thrown when an entity is not found- Entity type
- Entity ID
- Search criteria
- Custom message
AppBusinessException
: Thrown when business rules are violated- Business rule code
- Business rule message
- Additional context
AppValidationException
: Thrown when validation fails- Validation errors collection
- Field-specific errors
- Custom validation messages
AppAuthorizationException
: Thrown when authorization fails- Required permissions
- Access denied reason
- User context
AppUserFriendlyException
: Thrown for user-friendly error messages- User-friendly message
- Technical details (optional)
- Suggested actions
Exception Interfaces
Core Interfaces
IHasErrorCode
: Interface for exceptions with error codesIHasErrorDetails
: Interface for exceptions with detailed error informationIHasTimestamp
: Interface for exceptions with timestamp informationIHasCorrelationId
: Interface for exceptions with correlation ID trackingIHasStatusCode
: Interface for exceptions with HTTP status codesIHasValidationErrors
: Interface for exceptions with validation errors
Usage
Basic Exception Usage
// Entity not found
throw new AppEntityNotFoundException(typeof(User), userId);
// Business rule violation
throw new AppBusinessException("USER_INACTIVE", "User account is inactive");
// Authorization error
throw new AppAuthorizationException("ADMIN_REQUIRED", "Admin access required");
// User-friendly error
throw new AppUserFriendlyException(
"Unable to process your request at this time",
"Please try again later or contact support"
);
AppException Methods
AppException
provides a fluent API for configuring exception properties:
// Basic usage
throw new AppBusinessException("User account is inactive")
.WithCode("USER:INACTIVE:1001")
.WithDetails("Account was deactivated by admin")
.WithStatusCode(400)
.WithCorrelationId("corr-123")
.WithData("UserId", userId)
.AppendData(new Dictionary<string, object>
{
{ "LastLoginDate", lastLoginDate },
{ "DeactivationReason", reason }
});
Available Methods
WithData(string name, object value)
: Adds a single key-value pair to exception dataAppendData(IDictionary<string, object> data)
: Adds multiple key-value pairs to exception dataWithCode(string code)
: Sets the error codeWithDetails(string details)
: Sets the error detailsWithStatusCode(int statusCode)
: Sets the HTTP status codeWithCorrelationId(string correlationId)
: Sets the correlation ID
Features
- Standardized exception handling
- HTTP status code mapping
- Validation error collection
- Business rule violation handling
- Entity not found handling
- User-friendly messages
- Correlation tracking
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 was computed. 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. |
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Fermat.Domain.Exceptions:
Package | Downloads |
---|---|
Fermat.EntityFramework.Shared
A set of shared extensions for Fermat Entity Framework projects. |
|
Fermat.Cqrs.Behaviors
A library that provides behaviors for CQRS (Command Query Responsibility Segregation) patterns in .NET applications, enhancing command and query processing with features like validation, logging, and retry policies. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.0.1 | 127 | 7/27/2025 |