88 lines
2.6 KiB
C#
88 lines
2.6 KiB
C#
namespace Lagerbestand.Exceptions;
|
|
|
|
/// <summary>
|
|
/// Base exception for storage location related errors.
|
|
/// </summary>
|
|
public class StorageLocationException : Exception
|
|
{
|
|
public StorageLocationException(string message) : base(message) { }
|
|
public StorageLocationException(string message, Exception innerException) : base(message, innerException) { }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when a location code is invalid or malformed.
|
|
/// </summary>
|
|
public class InvalidLocationCodeException : StorageLocationException
|
|
{
|
|
public string? LocationCode { get; }
|
|
|
|
public InvalidLocationCodeException(string locationCode)
|
|
: base($"Ungültiger Lagerplatz-Code: '{locationCode}'. Das Format muss ABCD sein (z.B. 1101).")
|
|
{
|
|
LocationCode = locationCode;
|
|
}
|
|
|
|
public InvalidLocationCodeException(string locationCode, string reason)
|
|
: base($"Ungültiger Lagerplatz-Code '{locationCode}': {reason}")
|
|
{
|
|
LocationCode = locationCode;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when trying to use an occupied location.
|
|
/// </summary>
|
|
public class LocationOccupiedException : StorageLocationException
|
|
{
|
|
public string LocationCode { get; }
|
|
public Guid? TireStackId { get; }
|
|
|
|
public LocationOccupiedException(string locationCode)
|
|
: base($"Der Lagerplatz '{locationCode}' ist bereits belegt.")
|
|
{
|
|
LocationCode = locationCode;
|
|
}
|
|
|
|
public LocationOccupiedException(string locationCode, Guid tireStackId)
|
|
: base($"Der Lagerplatz '{locationCode}' ist bereits mit Reifenstapel belegt.")
|
|
{
|
|
LocationCode = locationCode;
|
|
TireStackId = tireStackId;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when a location is not found.
|
|
/// </summary>
|
|
public class LocationNotFoundException : StorageLocationException
|
|
{
|
|
public string? LocationCode { get; }
|
|
public Guid? LocationId { get; }
|
|
|
|
public LocationNotFoundException(string locationCode)
|
|
: base($"Lagerplatz '{locationCode}' wurde nicht gefunden.")
|
|
{
|
|
LocationCode = locationCode;
|
|
}
|
|
|
|
public LocationNotFoundException(Guid locationId)
|
|
: base($"Lagerplatz mit ID '{locationId}' wurde nicht gefunden.")
|
|
{
|
|
LocationId = locationId;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when a location code already exists.
|
|
/// </summary>
|
|
public class LocationCodeExistsException : StorageLocationException
|
|
{
|
|
public string LocationCode { get; }
|
|
|
|
public LocationCodeExistsException(string locationCode)
|
|
: base($"Der Lagerplatz-Code '{locationCode}' existiert bereits.")
|
|
{
|
|
LocationCode = locationCode;
|
|
}
|
|
}
|