Sep06ServerErrorException

class Sep06ServerErrorException(val statusCode: Int, val errorMessage: String? = null) : Sep06Exception

Exception thrown when the SEP-6 anchor returns a server error (HTTP 5xx).

Indicates that the anchor experienced an internal error while processing the request. This is typically a temporary condition that may be resolved by retrying the request. Common causes:

  • Anchor service temporarily unavailable (503)

  • Internal server error (500)

  • Bad gateway (502)

  • Gateway timeout (504)

  • Anchor maintenance mode

  • Database or backend service issues

Recovery actions:

  • Retry the request after a delay

  • Use exponential backoff for retries

  • Check anchor status page if available

  • Contact anchor support if the problem persists

Example - Handle server error with retry:

suspend fun depositWithRetry(
sep06Service: Sep06Service,
assetCode: String,
jwt: String,
maxRetries: Int = 3
): Sep06DepositResponse? {
var delay = 1000L

repeat(maxRetries) { attempt ->
try {
return sep06Service.deposit(assetCode, jwt)
} catch (e: Sep06ServerErrorException) {
println("Server error (${e.statusCode}): ${e.errorMessage ?: "Unknown error"}")

if (attempt < maxRetries - 1) {
println("Retrying in ${delay}ms...")
delay(delay)
delay *= 2 // Exponential backoff
}
}
}

println("Max retries reached")
return null
}

Example - Handle different status codes:

suspend fun handleServerError(
sep06Service: Sep06Service,
assetCode: String,
jwt: String
): Sep06DepositResponse? {
try {
return sep06Service.deposit(assetCode, jwt)
} catch (e: Sep06ServerErrorException) {
when (e.statusCode) {
503 -> {
println("Service temporarily unavailable, try again later")
}
504 -> {
println("Gateway timeout, the anchor may be overloaded")
}
else -> {
println("Server error (${e.statusCode}): ${e.errorMessage ?: "Unknown error"}")
}
}
return null
}
}

See also:

Constructors

Link copied to clipboard
constructor(statusCode: Int, errorMessage: String? = null)

Properties

Link copied to clipboard
expect open val cause: Throwable?
Link copied to clipboard

Optional error message from the anchor, if available

Link copied to clipboard
expect open val message: String?
Link copied to clipboard

HTTP status code returned by the anchor (5xx)

Functions

Link copied to clipboard
open override fun toString(): String