Generator Changes at 9/27/2025 8:46:36 AM
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
namespace CMSMicroservice.Application.Common.Exceptions;
|
||||
|
||||
public class DuplicateException : Exception
|
||||
{
|
||||
public DuplicateException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public DuplicateException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public DuplicateException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public DuplicateException(string name, object key)
|
||||
: base($"Entity \"{name}\" ({key}) already exists.")
|
||||
{
|
||||
}
|
||||
|
||||
public DuplicateException(string name, string field, object? key)
|
||||
: base($"Entity \"{name}\" field \"{field}\" ({key}) already exists.")
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace CMSMicroservice.Application.Common.Exceptions;
|
||||
|
||||
public class ForbiddenAccessException : Exception
|
||||
{
|
||||
public ForbiddenAccessException() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace CMSMicroservice.Application.Common.Exceptions;
|
||||
|
||||
public class NotFoundException : Exception
|
||||
{
|
||||
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.")
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using FluentValidation.Results;
|
||||
|
||||
namespace CMSMicroservice.Application.Common.Exceptions;
|
||||
|
||||
public class ValidationException : Exception
|
||||
{
|
||||
public ValidationException()
|
||||
: base("One or more validation failures have occurred.")
|
||||
{
|
||||
Errors = new Dictionary<string, string[]>();
|
||||
}
|
||||
|
||||
public ValidationException(IEnumerable<ValidationFailure> failures)
|
||||
: this()
|
||||
{
|
||||
Errors = failures
|
||||
.GroupBy(e => e.PropertyName, e => e.ErrorMessage)
|
||||
.ToDictionary(failureGroup => failureGroup.Key, failureGroup => failureGroup.ToArray());
|
||||
}
|
||||
|
||||
public IDictionary<string, string[]> Errors { get; }
|
||||
}
|
||||
Reference in New Issue
Block a user