LocalData/Sources/LocalData/Models/MigrationError.swift
Matt Bruce 2a42e3dba0 Update Audit, Helpers, Migrations (+2 more)
Summary:
- Sources: update Audit, Helpers, Migrations (+2 more)

Stats:
- 29 files changed, 471 insertions(+), 25 deletions(-)
2026-01-18 13:43:12 -06:00

49 lines
1.9 KiB
Swift

import Foundation
/// Migration-specific error types.
///
/// These errors describe why a migration failed or could not run, and are used
/// in ``MigrationResult`` for reporting.
public enum MigrationError: Error, Sendable, Equatable {
/// Validation failed before migration could run.
case validationFailed(String)
/// Transformation failed while converting source to destination.
case transformationFailed(String)
/// Underlying storage error occurred.
case storageFailed(StorageError)
/// Conditional migration criteria were not met.
case conditionalMigrationFailed
/// A migration is already in progress for the key.
case migrationInProgress
/// No source data was found to migrate.
case sourceDataNotFound
/// Source and destination types are incompatible.
case incompatibleTypes(String)
/// Aggregation failed while combining multiple sources.
case aggregationFailed(String)
}
extension MigrationError: LocalizedError {
/// Localized description for display or logging.
public var errorDescription: String? {
switch self {
case .validationFailed(let message):
return "Migration validation failed: \(message)"
case .transformationFailed(let message):
return "Data transformation failed: \(message)"
case .storageFailed(let storageError):
return "Storage operation failed: \(storageError.localizedDescription)"
case .conditionalMigrationFailed:
return "Conditional migration criteria not met"
case .migrationInProgress:
return "Migration already in progress"
case .sourceDataNotFound:
return "No data found in migration source"
case .incompatibleTypes(let message):
return "Type incompatibility: \(message)"
case .aggregationFailed(let message):
return "Data aggregation failed: \(message)"
}
}
}