Skip to main content
All SDK operations throw GrantivaError, which conforms to LocalizedError.

Error types

ErrorWhenSuggested action
deviceNotSupportedApp Attest unavailable (simulator, old device)Fall back to API key mode for development
attestationNotAvailableApp Attest not supported in this regionDegrade gracefully
networkError(Error)Network communication failedRetry with backoff
validationFailedServer rejected the attestationDevice may be compromised — block or challenge
tokenExpiredJWT token has expiredCall refreshToken() or validateAttestation()
configurationErrorInvalid Bundle ID or Team IDCheck SDK initialization
keyGenerationFailedCan’t create attestation keyRetry; may indicate Keychain issue
challengeExpiredServer challenge timed outRetry — the SDK handles this automatically
invalidResponseUnexpected server response formatCheck SDK/server version compatibility
rateLimitedToo many requestsBack off and retry after delay
feedbackNotAvailableFeedback not enabled for this tenantCheck your plan includes feedback

Example

do {
    let result = try await grantiva.validateAttestation()
} catch let error as GrantivaError {
    switch error {
    case .deviceNotSupported:
        // Use API key mode for development
        print("Run on a real device for attestation")
    case .networkError(let underlying):
        // Retry logic
        print("Network error: \(underlying.localizedDescription)")
    case .validationFailed:
        // Device integrity issue
        print("Device verification failed")
    case .tokenExpired:
        // Re-attest
        let refreshed = try await grantiva.refreshToken()
    case .rateLimited:
        // Back off
        try await Task.sleep(for: .seconds(5))
    default:
        print(error.localizedDescription)
    }
}

Localized descriptions

Every GrantivaError case provides a human-readable errorDescription:
GrantivaError.deviceNotSupported.errorDescription
// "App Attest requires iOS 14.0 or later and is not available in simulator"

GrantivaError.rateLimited.errorDescription
// "You have exceeded the rate limit for this action"