rwadurian/backend/services/wallet-service/src/shared/exceptions/domain.exception.ts

42 lines
1.1 KiB
TypeScript

export class DomainError extends Error {
constructor(message: string) {
super(message);
this.name = 'DomainError';
}
}
export class InsufficientBalanceError extends DomainError {
constructor(assetType: string, required: string, available: string) {
super(`Insufficient ${assetType} balance: required ${required}, available ${available}`);
this.name = 'InsufficientBalanceError';
}
}
export class WalletFrozenError extends DomainError {
constructor(walletId: string) {
super(`Wallet ${walletId} is frozen`);
this.name = 'WalletFrozenError';
}
}
export class WalletNotFoundError extends DomainError {
constructor(identifier: string) {
super(`Wallet not found: ${identifier}`);
this.name = 'WalletNotFoundError';
}
}
export class DuplicateTransactionError extends DomainError {
constructor(txHash: string) {
super(`Duplicate transaction: ${txHash}`);
this.name = 'DuplicateTransactionError';
}
}
export class InvalidOperationError extends DomainError {
constructor(message: string) {
super(message);
this.name = 'InvalidOperationError';
}
}