initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
namespace Indotalent.ConfigBackEnd.Exceptions;
|
||||
|
||||
public class AlreadyExistsException : Exception
|
||||
{
|
||||
public AlreadyExistsException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public AlreadyExistsException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public AlreadyExistsException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public AlreadyExistsException(string name, object key)
|
||||
: base($"Entity \"{name}\" ({key}) already exists.")
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Indotalent.ConfigBackEnd.Exceptions;
|
||||
|
||||
public class ForbiddenAccessException : Exception
|
||||
{
|
||||
public ForbiddenAccessException() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public ForbiddenAccessException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ForbiddenAccessException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Indotalent.ConfigBackEnd.Exceptions;
|
||||
|
||||
public class MismatchException : Exception
|
||||
{
|
||||
public MismatchException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public MismatchException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public MismatchException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public MismatchException(string name, object expected, object actual)
|
||||
: base($"Mismatch detected for \"{name}\". Expected: {expected}, but received: {actual}.")
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Indotalent.ConfigBackEnd.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,36 @@
|
||||
namespace Indotalent.ConfigBackEnd.Exceptions;
|
||||
|
||||
using FluentValidation.Results;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public class ValidationException : Exception
|
||||
{
|
||||
public IDictionary<string, string[]> Errors { get; }
|
||||
|
||||
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 ValidationException(string message)
|
||||
: base(message)
|
||||
{
|
||||
Errors = new Dictionary<string, string[]>();
|
||||
}
|
||||
|
||||
public ValidationException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
Errors = new Dictionary<string, string[]>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user