Levge.Exceptions 1.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Levge.Exceptions --version 1.1.1
                    
NuGet\Install-Package Levge.Exceptions -Version 1.1.1
                    
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="Levge.Exceptions" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Levge.Exceptions" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Levge.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 Levge.Exceptions --version 1.1.1
                    
#r "nuget: Levge.Exceptions, 1.1.1"
                    
#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 Levge.Exceptions@1.1.1
                    
#: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=Levge.Exceptions&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Levge.Exceptions&version=1.1.1
                    
Install as a Cake Tool

<img src="icon.png" width="100" height="100" alt="Levge.Exceptions logo" />

Levge.Exceptions

Build Status NuGet License

English | T�rk�e

Description

Levge.Exceptions provides a centralized exception library for use across the Levge .NET ecosystem. It offers structured, semantic exception types that help create more maintainable and consistent error handling.

Features

  • Base exception class for all Levge exceptions
  • Specialized exceptions for common scenarios (not found, validation, conflict, unauthorized)
  • Clean integration with HTTP status codes
  • Consistent error messaging
  • Built for .NET 8.0

Installation

Install via NuGet Package Manager:dotnet add package Levge.Exceptions

Usage

Basic Usage

using Levge.Exceptions;

// Basic exception throw new LevgeException("An error occurred in a Levge component.");

// Not found exception throw new LevgeNotFoundException("User", 42);

Validation Exceptions

// Single field validation throw new LevgeValidationException("Email", "Invalid email format.");

// Multiple field validations throw new LevgeValidationException(new Dictionary<string, string[]> { ["Email"] = new[] { "Required" }, ["Password"] = new[] { "Too short", "Must contain a number" } });

Authorization and Conflict Exceptions

// Unauthorized exception throw new LevgeUnauthorizedException();

// Conflict exception throw new LevgeConflictException("Resource already exists.");

// Field-specific conflict throw LevgeConflictException.ForField("Email", "test@example.com");

API Documentation

LevgeException

Base exception class for all custom Levge exceptions.

Constructors
  • LevgeException(): Initializes a new instance with default settings.
  • LevgeException(string message): Initializes a new instance with the specified message.
  • LevgeException(string message, Exception innerException): Initializes a new instance with the specified message and inner exception.

LevgeNotFoundException

Exception thrown when a requested resource cannot be found.

Constructors
  • LevgeNotFoundException(string resource, object? key = null): Initializes a new instance with the specified resource name and optional key.

LevgeValidationException

Exception thrown when validation errors occur.

Properties
  • IReadOnlyDictionary<string, string[]> Errors: Gets a dictionary of field names and their associated validation error messages.
Constructors
  • LevgeValidationException(Dictionary<string, string[]> errors): Initializes a new instance with multiple validation errors.
  • LevgeValidationException(string field, string message): Initializes a new instance with a single validation error.

LevgeUnauthorizedException

Exception thrown when a user is not authorized to perform an action or access a resource.

Constructors
  • LevgeUnauthorizedException(): Initializes a new instance with a default message.
  • LevgeUnauthorizedException(string message): Initializes a new instance with a specified message.
  • LevgeUnauthorizedException(string message, Exception innerException): Initializes a new instance with a specified message and inner exception.

LevgeConflictException

Exception thrown when a resource conflict occurs, typically when trying to create a resource that already exists.

Constructors
  • LevgeConflictException(string message = "Resource already exists."): Initializes a new instance with an optional custom message.
Methods
  • ForField(string field, object? value = null): Creates a new instance for a specific field that is already in use.

Dependencies

  • .NET 8.0

License

MIT � Levge

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 (3)

Showing the top 3 NuGet packages that depend on Levge.Exceptions:

Package Downloads
Levge.Identity

Identity and authentication services for .NET applications.

Levge.Domain

Domain entity, interface, and enumeration base types for Levge projects.

Levge.ConsistentResponse

A library for standardizing API responses in ASP.NET Core applications with consistent formatting, error handling, and exception middleware.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.43 221 6/24/2025
1.1.42 142 6/24/2025
1.1.41 219 6/22/2025
1.1.31 99 6/21/2025
1.1.1 101 6/21/2025
1.1.0 379 6/17/2025
1.0.1 179 6/17/2025
1.0.0 245 6/16/2025