Errors
All SDK errors derive fromFourMicaError. Import the specific classes to branch on failure type.
The package root exports the errors you branch on most often. The rest import
from
fourmica_sdk.errors: the AuthError subclasses,
SponsorshipTransportError, and contract reverts such as
InsufficientAvailableError, InsufficientLiquidityError, and PausedError.Coded refusals
When core refuses with a stable code, the SDK raises aCoreRefusalError subclass carrying the decoded details. Each is also an RpcError, so handlers written against RpcError keep catching them. Branch on the class (or .code), not the message.
The client that receives one of the last four records core’s clock and drops the stale cycle. The next payment it builds with
new_payment is scoped and stamped correctly.
Unknown outcomes
A transaction that has left the wallet cannot be called back, and an answer that never arrives does not mean it failed. The SDK reports that case asOutcomeUnknownError, never as an ordinary failure, so that a retry loop does not send the same money twice.
TransactionOutcomeUnknownError says how far the transaction got:
stage == "broadcast": it was handed to the chain’s node, and no usable answer came back: a timeout, a dropped connection, a gateway’s 5xx, an HTTP 408, or a JSON-RPC internal error (-32603). The node may have taken it, andtx_hashisNone.stage == "receipt": the node accepted it, astx_hash, and its receipt was not seen in time. It may still be mined.
ContractError: nothing was sent. A SponsorshipTransportError means the facilitator never received the request, so it cannot have acted on it.
client is a FourMica session.
List the subclass first: Python runs the first except clause that matches.
Two results are not exceptions at all. client.settle() records an unknown outcome as a result with status == "unknown", and client.deposit() returns status="pending" when the transaction is mined and core has not counted it yet. Check the first before settling again, and wait on the second with await result.spendable().
Receipt errors
client.payment.verify_guarantee and verify_guarantee_receipt raise these PaymentErrors:
Distinguishing errors
Import the classes you want to handle and give each its ownexcept clause, most specific first.
Every error derives from
FourMicaError, so you can catch that base class to
handle any SDK failure in one place.Next steps
Overview
Install the SDK and see the capabilities at a glance.
Client operations
Deposit collateral, sign payments, and settle cleared cycles.