Errors and retries
Every failure the SDK throws is a MountayaError. The client retries what is worth retrying before it gives up.
.api is an answer the API sent, with its status, code, errors and requestId. .connection is a call that got no answer.
A 402 is fixed in your agreement or billing settings, not in code.
code is an APIErrorCode, so you branch on a member instead of a string. hasCode(_:) looks at every entry:
Retries are on: two retries with backoff, on 429, 502, 503, 504 and dropped connections. Change the policy for a client, or for one call:
The client's timeout is 30 seconds. Give one call 5 seconds, and withdraw the whole call by cancelling its task:
A cancelled call throws CancellationError, never a MountayaError. SwiftUI's .task cancels for you when its view goes away.
onResponse is told of every answer, successes included:
Quote the requestId to support: it is the id the API recorded the request under.