Move DiamondBankException to its own class #5

Merged
SKBotNL merged 1 commits from master into master 2025-06-11 15:44:41 -04:00
3 changed files with 33 additions and 64 deletions

No files matched your search

@@ -12,38 +12,6 @@ import java.util.concurrent.CompletableFuture
@OptIn(DelicateCoroutinesApi::class)
class DiamondBankAPIJava(private var postgreSQL: PostgreSQL) {
sealed class DiamondBankException(message: String) : Exception(message) {
object TransactionsLockedException : DiamondBankException("Transactions for player are locked") {
@Suppress("unused")
private fun readResolve(): Any = TransactionsLockedException
}
object EconomyDisabledException : DiamondBankException("Economy is disabled") {
@Suppress("unused")
private fun readResolve(): Any = EconomyDisabledException
}
object InvalidPlayerException : DiamondBankException("Invalid player") {
@Suppress("unused")
private fun readResolve(): Any = InvalidPlayerException
}
object PayerNotOnlineException : DiamondBankException("Payer is not online") {
@Suppress("unused")
private fun readResolve(): Any = PayerNotOnlineException
}
object PlayerNotOnlineException : DiamondBankException("Player is not online") {
@Suppress("unused")
private fun readResolve(): Any = PlayerNotOnlineException
}
object OtherException : DiamondBankException("Other exception") {
@Suppress("unused")
private fun readResolve(): Any = OtherException
}
}
/**
* WARNING: blocking, if the player has a transaction lock applied this function will wait until its released
* @param transactionReason the reason for this transaction for in the transaction log
@@ -10,38 +10,6 @@ import java.util.*
@OptIn(DelicateCoroutinesApi::class)
class DiamondBankAPIKotlin(private var postgreSQL: PostgreSQL) {
sealed class DiamondBankException(message: String) : Exception(message) {
object TransactionsLockedException : DiamondBankException("Transactions for player are locked") {
@Suppress("unused")
private fun readResolve(): Any = TransactionsLockedException
}
object EconomyDisabledException : DiamondBankException("Economy is disabled") {
@Suppress("unused")
private fun readResolve(): Any = EconomyDisabledException
}
object InvalidPlayerException : DiamondBankException("Invalid player") {
@Suppress("unused")
private fun readResolve(): Any = InvalidPlayerException
}
object PayerNotOnlineException : DiamondBankException("Payer is not online") {
@Suppress("unused")
private fun readResolve(): Any = PayerNotOnlineException
}
object PlayerNotOnlineException : DiamondBankException("Player is not online") {
@Suppress("unused")
private fun readResolve(): Any = PlayerNotOnlineException
}
object OtherException : DiamondBankException("Other exception") {
@Suppress("unused")
private fun readResolve(): Any = OtherException
}
}
/**
* WARNING: blocking, if the player has a transaction lock applied this function will wait until its released
* @param transactionReason the reason for this transaction for in the transaction log
@@ -0,0 +1,33 @@
package net.trueog.diamondbankog
sealed class DiamondBankException(message: String) : Exception(message) {
object TransactionsLockedException : DiamondBankException("Transactions for player are locked") {
@Suppress("unused")
private fun readResolve(): Any = TransactionsLockedException
}
object EconomyDisabledException : DiamondBankException("Economy is disabled") {
@Suppress("unused")
private fun readResolve(): Any = EconomyDisabledException
}
object InvalidPlayerException : DiamondBankException("Invalid player") {
@Suppress("unused")
private fun readResolve(): Any = InvalidPlayerException
}
object PayerNotOnlineException : DiamondBankException("Payer is not online") {
@Suppress("unused")
private fun readResolve(): Any = PayerNotOnlineException
}
object PlayerNotOnlineException : DiamondBankException("Player is not online") {
@Suppress("unused")
private fun readResolve(): Any = PlayerNotOnlineException
}
object OtherException : DiamondBankException("Other exception") {
@Suppress("unused")
private fun readResolve(): Any = OtherException
}
}