Sep31UnknownResponseException

class Sep31UnknownResponseException(message: String, val statusCode: Int, val responseBody: String, val rawResponseBody: String? = null) : Sep31Exception

Exception thrown when the Receiving Anchor returns an unexpected HTTP status code.

Raised when the anchor responds with a status code not covered by the SEP-31 specification or the SDK's per-endpoint dispatch matrix. Typical scenarios:

  • 5xx server errors (500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout)

  • 3xx redirects (the SDK configures followRedirects = false, so a 302 surfaces here rather than being followed)

  • 4xx codes outside the documented 400/401/403/404 set (e.g., 429 Too Many Requests)

The raw responseBody is captured so callers can implement custom diagnostics or retry policies. The body is already truncated to the SDK's response-size cap; no additional truncation is necessary.

Recovery actions:

  • Inspect statusCode and responseBody for diagnostic information

  • Retry the request with exponential backoff if the error appears transient (5xx)

  • Contact the Receiving Anchor operator if the problem persists

Example - Handle unknown response:

try {
val response = sep31Service.postTransactions(request, jwt)
} catch (e: Sep31UnknownResponseException) {
println("Unexpected HTTP ${e.statusCode}: ${e.message}")
println("Body: ${e.responseBody}")
}

See also:

Parameters

message

Sanitized error message describing the unexpected response.

Constructors

Link copied to clipboard
constructor(message: String, statusCode: Int, responseBody: String, rawResponseBody: String? = null)

Properties

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

Anchor response body for local debugging — see the rawResponseBody convention on Sep31Exception. Identical to responseBody except JWT-shaped substrings are not redacted. null when no body was captured.

Link copied to clipboard

The sanitized response body — size-capped, control characters stripped, and JWT-shaped substrings replaced with <redacted-jwt>. Safe to log.

Link copied to clipboard

The HTTP status code returned by the Receiving Anchor.

Functions

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