feat: added exceptions
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.ccoin.exceptions
|
||||
|
||||
class InvalidTransactionException(
|
||||
message: String,
|
||||
val transactionHash: String? = null
|
||||
) : CCoinException(
|
||||
message = message,
|
||||
errorCode = "INVALID_TRANSACTION"
|
||||
)
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user