PushError

public enum PushError : Error, LocalizedError, Sendable

Errors that can occur during Push operations.

PushError provides comprehensive error handling for all Push-related operations, including credential management, URI parsing, notification processing, and policy enforcement. Each error case includes detailed information to help developers diagnose and resolve issues.

Error Categories

  • Initialization: Errors during client initialization
  • Credential Management: Errors related to storing, retrieving, and managing credentials
  • URI Parsing: Errors that occur when parsing pushauth:// or mfauth:// URIs
  • Notification Processing: Errors during push notification handling
  • Policy: Errors related to policy enforcement and credential locking
  • Network: Errors during communication with the server
  • Storage: Errors related to persistent storage operations

Usage Examples

do {
    let credential = try await client.addCredentialFromUri(uri)
    let notification = try await client.processNotification(userInfo)
} catch let error as PushError {
    switch error {
    case .invalidUri(let message):
        print("Invalid URI format: \(message)")
        // Show user-friendly error about QR code format
    case .credentialLocked(let id):
        print("Credential is locked: \(id)")
        // Prompt user for authentication or wait for unlock
    case .networkFailure(let message, _):
        print("Network error: \(message)")
        // Retry or show offline message
    default:
        print("Push error: \(error.localizedDescription)")
    }
}

Initialization Errors

  • The Push client has not been initialized.

    Declaration

    Swift

    case notInitialized
  • Initialization of the Push client failed.

    Declaration

    Swift

    case initializationFailed(String, Error?)

URI Parsing Errors

  • The provided URI is invalid or malformed.

    Declaration

    Swift

    case invalidUri(String)
  • A required parameter is missing from the URI.

    Declaration

    Swift

    case missingRequiredParameter(String)
  • A parameter value is invalid or malformed.

    Declaration

    Swift

    case invalidParameterValue(String)
  • URI formatting failed during credential export.

    Declaration

    Swift

    case uriFormatting(String)

Type and Platform Errors

  • The push type is invalid or not supported.

    Declaration

    Swift

    case invalidPushType(String)
  • The platform is invalid or not supported.

    Declaration

    Swift

    case invalidPlatform(String)

Storage Errors

  • A storage operation failed.

    Declaration

    Swift

    case storageFailure(String, Error?)

Device Token Errors

  • The device token has not been set.

    Declaration

    Swift

    case deviceTokenNotSet

Handler Errors

Credential Errors

  • The specified credential was not found.

    Declaration

    Swift

    case credentialNotFound(String)
  • The credential is locked due to policy violation.

    Declaration

    Swift

    case credentialLocked(String)
  • A credential with the same issuer and account name already exists.

    Declaration

    Swift

    case duplicateCredential(issuer: String, accountName: String)

Notification Errors

  • The specified notification was not found.

    Declaration

    Swift

    case notificationNotFound(String)

Policy Errors

  • A policy violation occurred.

    Declaration

    Swift

    case policyViolation(String)

Registration Errors

  • Registration with the server failed.

    Declaration

    Swift

    case registrationFailed(String)

Network Errors

  • A network operation failed.

    Declaration

    Swift

    case networkFailure(String, Error?)

LocalizedError Conformance

  • Declaration

    Swift

    public var errorDescription: String? { get }