Skip to content

Commit

Permalink
WAL-1381: Expand error message of TransactionSubmitFailedException (#127
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Ifropc authored Mar 13, 2024
1 parent 50b9c34 commit 5d2b710
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ val jvmVersion = JavaVersion.VERSION_11

allprojects {
group = "org.stellar.wallet-sdk"
version = "1.2.2"
version = "1.3.0"
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.request.*
import io.ktor.http.*
import java.math.BigInteger
import java.util.*
import kotlinx.datetime.Clock
import mu.KotlinLogging
import org.stellar.sdk.Network
Expand All @@ -13,8 +15,6 @@ import org.stellar.walletsdk.exception.*
import org.stellar.walletsdk.horizon.AccountKeyPair
import org.stellar.walletsdk.util.Util.authGet
import org.stellar.walletsdk.util.Util.postJson
import java.math.BigInteger
import java.util.*

private val log = KotlinLogging.logger {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.stellar.walletsdk.exception

import java.math.BigDecimal
import org.stellar.sdk.AbstractTransaction
import org.stellar.sdk.responses.SubmitTransactionResponse

sealed class StellarException : WalletException {
constructor(message: String) : super(message)

constructor(message: String, cause: Exception) : super(message, cause)
}

Expand All @@ -20,10 +22,12 @@ class AccountNotEnoughBalanceException(

class TransactionSubmitFailedException(
val response: SubmitTransactionResponse,
val transaction: AbstractTransaction
) :
StellarException(
"Submit transaction failed with code ${response.resultCode ?: "<unknown>"}" +
".${response.operationsResultCodes ?. run { " Operation result codes: $this" } ?: ""}"
".${response.operationsResultCodes ?. run { " Operation result codes: $this" } ?: ""}" +
" Transaction XDR: ${transaction.toEnvelopeXdrBase64()}"
) {
val transactionResultCode = response.resultCode
val operationsResultCodes = response.operationsResultCodes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ internal constructor(
val response = server.submitTransaction(signedTransaction)

if (!response.isSuccess) {
throw TransactionSubmitFailedException(response)
throw TransactionSubmitFailedException(response, signedTransaction)
}

log.debug { "Transaction submitted with hash ${response.hash}" }
Expand All @@ -131,7 +131,7 @@ internal constructor(
val response = server.submitTransaction(signedTransaction)

if (!response.isSuccess) {
throw TransactionSubmitFailedException(response)
throw TransactionSubmitFailedException(response, signedTransaction)
}

log.debug { "Transaction submitted with hash ${response.hash}" }
Expand Down

0 comments on commit 5d2b710

Please sign in to comment.