OathStorageError

public enum OathStorageError : LocalizedError, Sendable

Storage-specific errors for OATH operations.

OathStorageError handles errors that occur at the storage layer, including iOS Keychain operations, file system access, and data persistence issues. These errors are typically system-related and may require different handling than application-level OathError cases.

Common Scenarios

  • Device Lock: Keychain access denied when device is locked
  • Storage Full: Insufficient space for storing credentials
  • Corruption: Data corruption in stored credentials
  • Permissions: App permissions insufficient for storage access

Usage Examples

do {
    let credentials = try await storage.getAllOathCredentials()
} catch let error as OathStorageError {
    switch error {
    case .accessDenied(let message):
        // Device may be locked or permissions missing
        print("Storage access denied: \(message)")
    case .storageCorrupted(let message):
        // May need to clear and reinitialize storage
        print("Storage corrupted: \(message)")
    case .storageFailure(let message, let underlying):
        // General storage error with potential underlying cause
        print("Storage failure: \(message)")
        if let underlying = underlying {
            print("Underlying error: \(underlying)")
        }
    default:
        print("Storage error: \(error.localizedDescription)")
    }
}
  • A general storage operation failed.

    Declaration

    Swift

    case storageFailure(String, _: Error? = nil)
  • A credential with the same ID already exists.

    Declaration

    Swift

    case duplicateCredential(String)
  • The storage is corrupted or in an invalid state.

    Declaration

    Swift

    case storageCorrupted(String)
  • Access to the storage was denied.

    Declaration

    Swift

    case accessDenied(String)

LocalizedError Implementation

  • Declaration

    Swift

    public var errorDescription: String? { get }
  • Declaration

    Swift

    public var failureReason: String? { get }
  • Declaration

    Swift

    public var recoverySuggestion: String? { get }