Fermion.Domain.Exceptions 1.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Fermion.Domain.Exceptions --version 1.0.0
                    
NuGet\Install-Package Fermion.Domain.Exceptions -Version 1.0.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="Fermion.Domain.Exceptions" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fermion.Domain.Exceptions" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Fermion.Domain.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 Fermion.Domain.Exceptions --version 1.0.0
                    
#r "nuget: Fermion.Domain.Exceptions, 1.0.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 Fermion.Domain.Exceptions@1.0.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=Fermion.Domain.Exceptions&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Fermion.Domain.Exceptions&version=1.0.0
                    
Install as a Cake Tool

Fermion.Domain.Exceptions

Fermion.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 Fermion.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 codes
  • IHasErrorDetails: Interface for exceptions with detailed error information
  • IHasTimestamp: Interface for exceptions with timestamp information
  • IHasCorrelationId: Interface for exceptions with correlation ID tracking
  • IHasStatusCode: Interface for exceptions with HTTP status codes
  • IHasValidationErrors: 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 data
  • AppendData(IDictionary<string, object> data): Adds multiple key-value pairs to exception data
  • WithCode(string code): Sets the error code
  • WithDetails(string details): Sets the error details
  • WithStatusCode(int statusCode): Sets the HTTP status code
  • WithCorrelationId(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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

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