Sep31InvalidResponseException

class Sep31InvalidResponseException(message: String, val statusCode: Int = 200, val rawResponseBody: String? = null) : Sep31Exception

Exception thrown when the Receiving Anchor returns a malformed response.

Raised when the anchor responded with an otherwise-successful HTTP status (200 or

  1. but the response body could not be parsed or was missing fields the SEP-31 spec marks as required. Common triggers:

  • The response body is not syntactically valid JSON

  • The response Content-Type is neither application/json nor application/problem+json

  • A required field is absent (for example, id on Sep31PostTransactionsResponse)

  • The GET /transactions/:id response is not wrapped in the spec-mandated {"transaction": {...}} envelope

  • The response exceeds the SDK's size cap (2 MB for /info, 256 KB for transaction responses)

The statusCode defaults to 200 because this exception only fires on a syntactically bad response inside an otherwise-successful HTTP status.

Recovery actions:

  • Verify the configured DIRECT_PAYMENT_SERVER URL points to a SEP-31 compliant anchor

  • Contact the Receiving Anchor operator if the failure persists

Example - Handle invalid response:

try {
val info = sep31Service.info(jwt = jwt)
} catch (e: Sep31InvalidResponseException) {
println("Malformed anchor response (HTTP ${e.statusCode}): ${e.message}")
}

See also:

Parameters

message

Sanitized error message describing the parsing failure.

Constructors

Link copied to clipboard
constructor(message: String, statusCode: Int = 200, 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. null when no body was captured (for example, content-type rejection before any body was read).

Link copied to clipboard

The HTTP status code that produced the malformed body (defaults to 200).

Functions

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