DeutschLernen/GermanApp/Domain/Exceptions/DomainException.cs
Lasse Rune Hansen d90e4792d6 Initial commit: GermanApp with Clean Architecture
- Domain layer: Lesson entity, GermanWord value object, repository interfaces
- Application layer: CQRS commands, DTOs with mapping
- Infrastructure layer: EF Core with SQLite, LessonRepository
- Presentation layer: Minimal API endpoints for lessons CRUD

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-05-31 18:14:51 +02:00

56 lines
1.3 KiB
C#

using System;
namespace GermanApp.Domain.Exceptions;
/// <summary>
/// Base exception for domain layer errors.
/// All domain-specific exceptions should inherit from this.
/// </summary>
public class DomainException : Exception
{
public DomainException(string message) : base(message)
{
}
public DomainException(string message, Exception innerException) : base(message, innerException)
{
}
}
/// <summary>
/// Exception thrown when a business rule validation fails.
/// </summary>
public class ValidationException : DomainException
{
public ValidationException(string message) : base(message)
{
}
public ValidationException(string message, Exception innerException) : base(message, innerException)
{
}
}
/// <summary>
/// Exception thrown when an entity is not found.
/// </summary>
public class NotFoundException : DomainException
{
public NotFoundException(string entityName, int id) : base($"{entityName} with id {id} not found")
{
}
public NotFoundException(string message) : base(message)
{
}
}
/// <summary>
/// Exception thrown when attempting to perform an invalid operation.
/// </summary>
public class InvalidOperationException : DomainException
{
public InvalidOperationException(string message) : base(message)
{
}
}