PrimerError is the error type delivered when a payment or checkout fails. Every error carries a stable errorId for programmatic handling, a diagnosticsId to share with Primer support, and (where applicable) a recoverySuggestion describing how to recover.
PrimerError conforms to LocalizedError and CustomNSError, so you also get localizedDescription for free and can bridge it to NSError when needed.How errors are delivered
You never construct aPrimerError yourself. The SDK delivers it to you through one of two channels, depending on how you present checkout.
| Channel | Where the error arrives |
|---|---|
| SwiftUI state | PrimerCheckoutState.failure(PrimerError) — receive the final state through the .primerCheckoutSession(session) { state in ... } modifier’s completion closure (or PrimerCheckout(clientToken:) { state in ... }) and switch on .failure. |
| Presenter delegate | PrimerCheckoutPresenterDelegate primerCheckoutPresenterDidFailWithError(_:) for UIKit / presenter-driven integrations. |
Properties
| Property | Type | Description |
|---|---|---|
errorId | String | Stable, kebab-case identifier for the error category (for example "invalid-client-token", "payment-cancelled", "apple-pay-no-cards-in-wallet"). Use this for programmatic branching. |
diagnosticsId | String | Unique per-occurrence diagnostics ID. Log it and provide it to Primer support when investigating an issue. |
recoverySuggestion | String? | Suggested recovery action when one applies (for example “Check if the token you have provided is a valid token”). nil when no recovery is available (for example a user-cancelled payment). |
errorDescription | String? | Human-readable description suitable for logging. Includes the errorId and diagnosticsId. Also surfaced as localizedDescription via LocalizedError. |
errorUserInfo | [String: Any] | NSError user-info dictionary. Includes "diagnosticsId" and a "createdAt" timestamp. |
underlyingErrorCode | String? | An underlying provider error code when one is available. Currently populated only for NOL Pay errors; nil otherwise. |
Handling an error
Receive the checkout state through the completion closure and, in the.failure branch, log the diagnosticsId and errorId. Branch on errorId only when you need behavior specific to a category (for example treating a cancellation differently from a hard failure).
PrimerError arrives through the delegate:
See also
PrimerCheckoutState
The checkout state that delivers
.failure(PrimerError).Handle the payment result
Handle success, failure, and dismissal end to end.
PrimerCheckoutPresenter
Receive failures through the presenter delegate.
ValidationResult
Inline field validation, distinct from checkout errors.