first commit
This commit is contained in:
21
MyNewProjectName.Domain/Exceptions/DomainException.cs
Normal file
21
MyNewProjectName.Domain/Exceptions/DomainException.cs
Normal 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
27
MyNewProjectName.Domain/Exceptions/NotFoundException.cs
Normal file
27
MyNewProjectName.Domain/Exceptions/NotFoundException.cs
Normal 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.")
|
||||
{
|
||||
}
|
||||
}
|
||||
27
MyNewProjectName.Domain/Exceptions/ValidationException.cs
Normal file
27
MyNewProjectName.Domain/Exceptions/ValidationException.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user