Init
This commit is contained in:
19
Prefab.Catalog/Domain/Exceptions/DomainException.cs
Normal file
19
Prefab.Catalog/Domain/Exceptions/DomainException.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace Prefab.Catalog.Domain.Exceptions;
|
||||
|
||||
public abstract class DomainException(string message) : Exception(message);
|
||||
|
||||
public sealed class CatalogNotFoundException(string resource, string identifier)
|
||||
: DomainException($"{resource} with identifier '{identifier}' was not found.")
|
||||
{
|
||||
public string Resource { get; } = resource;
|
||||
|
||||
public string Identifier { get; } = identifier;
|
||||
}
|
||||
|
||||
public sealed class CatalogConflictException(string resource, string identifier, string detail)
|
||||
: DomainException(detail)
|
||||
{
|
||||
public string Resource { get; } = resource;
|
||||
|
||||
public string Identifier { get; } = identifier;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Prefab.Catalog.Domain.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a domain rule violation caused by invalid user input.
|
||||
/// </summary>
|
||||
/// <param name="message">Details about the validation failure.</param>
|
||||
public sealed class DomainValidationException(string message) : DomainException(message);
|
||||
|
||||
14
Prefab.Catalog/Domain/Exceptions/DuplicateNameException.cs
Normal file
14
Prefab.Catalog/Domain/Exceptions/DuplicateNameException.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Prefab.Catalog.Domain.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an exception that is thrown when an attempt is made to create or add an entity with a name that already
|
||||
/// exists for the specified type.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the entity that caused the duplication error. Cannot be null.</param>
|
||||
/// <param name="type">The type of the entity for which the duplicate name was detected. Cannot be null.</param>
|
||||
internal class DuplicateNameException(string name, string type) : DomainException($"A {type} with the name {name} already exists.")
|
||||
{
|
||||
public string Name { get; } = name;
|
||||
|
||||
public string Type { get; } = type;
|
||||
}
|
||||
Reference in New Issue
Block a user