Files
demo-ddd-without-oop/csharp-fp2/Domain/InsufficientBalanceException.cs
T
2026-04-21 23:04:56 +01:00

18 lines
612 B
C#

namespace CsharpFp2.Domain;
/// Custom domain exception thrown when a withdrawal would cause the balance to go below zero
public sealed class InsufficientBalanceException : InvalidOperationException
{
public Money CurrentBalance { get; }
public Money RequestedAmount { get; }
public InsufficientBalanceException(Money currentBalance, Money requestedAmount)
: base(
$"Insufficient balance. Current: {currentBalance.Amount:0.00}, Requested: {requestedAmount.Amount:0.00}"
)
{
CurrentBalance = currentBalance;
RequestedAmount = requestedAmount;
}
}