first commit

This commit is contained in:
2026-02-26 14:04:18 +07:00
parent 57ac80a666
commit 4b7236493f
92 changed files with 4999 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
namespace MyNewProjectName.Domain.Exceptions;
/// <summary>
/// Base exception for domain layer
/// </summary>
public class DomainException : Exception
{
public DomainException()
{
}
public DomainException(string message)
: base(message)
{
}
public DomainException(string message, Exception innerException)
: base(message, innerException)
{
}
}

View File

@@ -0,0 +1,27 @@
namespace MyNewProjectName.Domain.Exceptions;
/// <summary>
/// Exception thrown when an entity is not found
/// </summary>
public class NotFoundException : DomainException
{
public NotFoundException()
: base()
{
}
public NotFoundException(string message)
: base(message)
{
}
public NotFoundException(string message, Exception innerException)
: base(message, innerException)
{
}
public NotFoundException(string name, object key)
: base($"Entity \"{name}\" ({key}) was not found.")
{
}
}

View File

@@ -0,0 +1,27 @@
namespace MyNewProjectName.Domain.Exceptions;
/// <summary>
/// Exception thrown when validation fails
/// </summary>
public class ValidationException : DomainException
{
public IDictionary<string, string[]> Errors { get; }
public ValidationException()
: base("One or more validation failures have occurred.")
{
Errors = new Dictionary<string, string[]>();
}
public ValidationException(string message)
: base(message)
{
Errors = new Dictionary<string, string[]>();
}
public ValidationException(IDictionary<string, string[]> errors)
: base("One or more validation failures have occurred.")
{
Errors = errors;
}
}