diff --git a/server/src/main/kotlin/org/ccoin/exceptions/CCoinException.kt b/server/src/main/kotlin/org/ccoin/exceptions/CCoinException.kt index e69de29..561dae3 100644 --- a/server/src/main/kotlin/org/ccoin/exceptions/CCoinException.kt +++ b/server/src/main/kotlin/org/ccoin/exceptions/CCoinException.kt @@ -0,0 +1,8 @@ +package org.ccoin.exceptions + +/** Base exception class for all CCoin-related exceptions */ +open class CCoinException( + message: String, + cause: Throwable? = null, + val errorCode: String? = null +) : Exception(message, cause) diff --git a/server/src/main/kotlin/org/ccoin/exceptions/InsufficientFundsException.kt b/server/src/main/kotlin/org/ccoin/exceptions/InsufficientFundsException.kt index e69de29..9ea0273 100644 --- a/server/src/main/kotlin/org/ccoin/exceptions/InsufficientFundsException.kt +++ b/server/src/main/kotlin/org/ccoin/exceptions/InsufficientFundsException.kt @@ -0,0 +1,10 @@ +package org.ccoin.exceptions + +class InsufficientFundsException( + val address: String, + val requestedAmount: Double, + val availableBalance: Double +) : CCoinException( + message = "Insufficient funds in wallet $address. Requested: $requestedAmount, Available: $availableBalance", + errorCode = "INSUFFICIENT_FUNDS" +) diff --git a/server/src/main/kotlin/org/ccoin/exceptions/InvalidTransactionException.kt b/server/src/main/kotlin/org/ccoin/exceptions/InvalidTransactionException.kt index e69de29..fa62638 100644 --- a/server/src/main/kotlin/org/ccoin/exceptions/InvalidTransactionException.kt +++ b/server/src/main/kotlin/org/ccoin/exceptions/InvalidTransactionException.kt @@ -0,0 +1,9 @@ +package org.ccoin.exceptions + +class InvalidTransactionException( + message: String, + val transactionHash: String? = null +) : CCoinException( + message = message, + errorCode = "INVALID_TRANSACTION" +) diff --git a/server/src/main/kotlin/org/ccoin/exceptions/WalletNotFoundException.kt b/server/src/main/kotlin/org/ccoin/exceptions/WalletNotFoundException.kt index e69de29..b0993f6 100644 --- a/server/src/main/kotlin/org/ccoin/exceptions/WalletNotFoundException.kt +++ b/server/src/main/kotlin/org/ccoin/exceptions/WalletNotFoundException.kt @@ -0,0 +1,8 @@ +package org.ccoin.exceptions + +class WalletNotFoundException( + val address: String +) : CCoinException( + message = "Wallet with address '$address' not found", + errorCode = "WALLET_NOT_FOUND" +)