Levge.Exceptions
1.1.45
dotnet add package Levge.Exceptions --version 1.1.45
NuGet\Install-Package Levge.Exceptions -Version 1.1.45
<PackageReference Include="Levge.Exceptions" Version="1.1.45" />
<PackageVersion Include="Levge.Exceptions" Version="1.1.45" />
<PackageReference Include="Levge.Exceptions" />
paket add Levge.Exceptions --version 1.1.45
#r "nuget: Levge.Exceptions, 1.1.45"
#:package Levge.Exceptions@1.1.45
#addin nuget:?package=Levge.Exceptions&version=1.1.45
#tool nuget:?package=Levge.Exceptions&version=1.1.45
<img src="src/Levge.Exceptions/icon.png" width="100" height="100" alt="Levge.Exceptions logo" />
Levge.Exceptions
Levge.Exceptions, tüm Levge paketlerinde tutarlı hata yönetimi sağlayan hafif bir kütüphanedir.
Özellikler
- ? Standartlaştırılmış istisnalar — uygulamalar genelinde birleşik hata yönetimi
- ? Özelleştirilmiş istisna türleri — farklı hata senaryoları için farklı istisnalar
- ? Basit ve anlaşılır API — kolayca anlamlı hata mesajları oluşturun
Kurulum
.NET CLI
dotnet add package Levge.Exceptions
Package Manager
Install-Package Levge.Exceptions
Yapılandırma
Özel bir yapılandırma gerekmez. Sadece paketi projenize ekleyin ve istisna türlerini kullanmaya başlayın.
Kullanım
İstisna Fırlatma
// Mesaj ile temel kullanım
throw new LevgeException("Bir şeyler ters gitti");
// Kaynak bilgisi ile bulunamadı (Not Found) istisnası
throw new LevgeNotFoundException("Kullanıcı", 123);
// Belirli bir alan için çakışma (Conflict) istisnası
throw LevgeConflictException.ForField("Email", "user@example.com");
// Birden fazla hata içeren doğrulama (Validation) istisnası
var errors = new Dictionary<string, string[]>
{
{ "KullaniciAdi", new[] { "Kullanıcı adı gereklidir" } },
{ "Email", new[] { "Geçersiz email formatı", "Email alan adına izin verilmiyor" } }
};
throw new LevgeValidationException(errors);
// Yetkisiz erişim (Unauthorized) istisnası
throw new LevgeUnauthorizedException();
Hatayı Yakalama (Exception Handling)
try
{
// İş mantığı kodları...
ValidateUser(user);
}
catch (LevgeNotFoundException ex)
{
// Kaynak bulunamadı (404)
logger.LogWarning("Kaynak bulunamadı: {Message}", ex.Message);
}
catch (LevgeValidationException ex)
{
// Doğrulama hatası (400)
foreach (var error in ex.Errors)
{
Console.WriteLine($"{error.Key}: {string.Join(", ", error.Value)}");
}
}
catch (LevgeException ex)
{
// Diğer Levge hataları
logger.LogError("Levge hatası: {Message}", ex.Message);
}
Mevcut İstisna Türleri
| İstisna Türü | Açıklama |
|---|---|
LevgeException |
Tüm Levge'ye özgü istisnalar için temel sınıf |
LevgeNotFoundException |
İstenen kaynak bulunamadığında fırlatılır |
LevgeConflictException |
Bir kaynak çakışması olduğunda fırlatılır (örn. mükerrer kayıt) |
LevgeUnauthorizedException |
Kullanıcının bir eylem için izni olmadığında fırlatılır |
LevgeValidationException |
Giriş doğrulaması ayrıntılı hata bilgileriyle başarısız olduğunda fırlatılır |
Lisans
MIT Lisansı. Detaylar için LICENSE dosyasına bakınız.
| 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 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.
-
net9.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.