Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
strategy:
matrix:
destination:
- platform=iOS Simulator,name=iPhone 16,OS=18.1
- platform=watchOS Simulator,name=Apple Watch SE (40mm) (2nd generation),OS=11.1
- platform=tvOS Simulator,name=Apple TV 4K (3rd generation) (at 1080p),OS=18.1
- platform=iOS Simulator,name=iPhone 17,OS=26.2
- platform=watchOS Simulator,name=Apple Watch SE 3 (40mm),OS=26.2
- platform=tvOS Simulator,name=Apple TV 4K (3rd generation) (at 1080p),OS=26.2
- platform=macOS,arch=arm64
with:
package: "OversizeCore"
Expand Down
2 changes: 0 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ let package = Package(
name: "OversizeCore", targets: ["OversizeCore"],
),
],
dependencies: [
],
targets: [
.target(
name: "OversizeCore",
Expand Down
86 changes: 86 additions & 0 deletions Sources/OversizeCore/Error/CalendarError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//
// Copyright © 2025 Alexander Romanov
// CalendarError.swift, created on 02.02.2025
//

import Foundation

public enum CalendarError: Error, LocalizedError, Sendable {
// MARK: - Core Operations

case saveFailed
case fetchFailed
case deleteFailed
case updateFailed

// MARK: - Permission

case accessDenied

// MARK: - Data

case itemNotFound

// MARK: - Unknown

case unknown(Error?)

// MARK: - LocalizedError

public var errorDescription: String? {
switch self {
case .saveFailed:
"Failed to save event"
case .fetchFailed:
"Failed to fetch events"
case .deleteFailed:
"Failed to delete event"
case .updateFailed:
"Failed to update event"
case .accessDenied:
"No access to calendar"
case .itemNotFound:
"Event not found"
case .unknown:
"Calendar error"
}
}

public var failureReason: String? {
switch self {
case .saveFailed:
"The event could not be saved to the calendar."
case .fetchFailed:
"The events could not be retrieved from the calendar."
case .deleteFailed:
"The event could not be deleted from the calendar."
case .updateFailed:
"The event could not be updated in the calendar."
case .accessDenied:
"Calendar access is restricted or denied."
case .itemNotFound:
"The requested event could not be found."
case let .unknown(error):
error?.localizedDescription ?? "An unknown calendar error occurred."
}
}

public var recoverySuggestion: String? {
switch self {
case .saveFailed:
"Check if the calendar is writable and try again."
case .fetchFailed:
"Refresh the calendar and try again."
case .deleteFailed:
"Make sure the event exists and try again."
case .updateFailed:
"Make sure the event exists and try again."
case .accessDenied:
"Allow calendar access in Settings and try again."
case .itemNotFound:
"Refresh the calendar and try again."
case .unknown:
"Please try again later."
}
}
}
110 changes: 110 additions & 0 deletions Sources/OversizeCore/Error/CloudError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
//
// Copyright © 2025 Alexander Romanov
// CloudError.swift, created on 02.02.2025
//

import Foundation

public enum CloudError: Error, LocalizedError, Sendable {
// MARK: - Core Operations

case saveFailed
case fetchFailed
case deleteFailed
case updateFailed

// MARK: - Account & Permission

case accessDenied
case noAccount

// MARK: - Network & Storage

case networkUnavailable
case quotaExceeded

// MARK: - Data

case decode

// MARK: - Unknown

case unknown(Error?)

// MARK: - LocalizedError

public var errorDescription: String? {
switch self {
case .saveFailed:
"Failed to save to iCloud"
case .fetchFailed:
"Failed to fetch from iCloud"
case .deleteFailed:
"Failed to delete from iCloud"
case .updateFailed:
"Failed to update in iCloud"
case .accessDenied:
"No access to iCloud"
case .noAccount:
"No iCloud account"
case .networkUnavailable:
"iCloud network unavailable"
case .quotaExceeded:
"iCloud storage full"
case .decode:
"iCloud data could not be read"
case .unknown:
"iCloud error"
}
}

public var failureReason: String? {
switch self {
case .saveFailed:
"The data could not be saved to iCloud."
case .fetchFailed:
"The data could not be retrieved from iCloud."
case .deleteFailed:
"The data could not be deleted from iCloud."
case .updateFailed:
"The data could not be updated in iCloud."
case .accessDenied:
"iCloud access is restricted or denied."
case .noAccount:
"An iCloud account is required."
case .networkUnavailable:
"The network connection to iCloud is unavailable."
case .quotaExceeded:
"Your iCloud storage quota has been exceeded."
case .decode:
"The iCloud data format was not recognized."
case let .unknown(error):
error?.localizedDescription ?? "An unknown iCloud error occurred."
}
}

public var recoverySuggestion: String? {
switch self {
case .saveFailed:
"Check your internet connection and iCloud storage, then try again."
case .fetchFailed:
"Check your internet connection and try again."
case .deleteFailed:
"Make sure the item exists and try again."
case .updateFailed:
"Make sure the item exists and try again."
case .accessDenied:
"Sign in to iCloud in Settings and try again."
case .noAccount:
"Sign in to iCloud in Settings and try again."
case .networkUnavailable:
"Check your internet connection and try again."
case .quotaExceeded:
"Free up iCloud storage or upgrade your plan."
case .decode:
"Try refreshing the data or reinstalling the app."
case .unknown:
"Please try again later."
}
}
}
83 changes: 83 additions & 0 deletions Sources/OversizeCore/Error/ContactsError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// Copyright © 2025 Alexander Romanov
// ContactsError.swift, created on 01.02.2025
//

import Foundation

public enum ContactsError: Error, LocalizedError, Sendable {
// MARK: - Core Operations

case saveFailed
case fetchFailed
case deleteFailed
case updateFailed

// MARK: - Permission

case accessDenied

// MARK: - Unknown

case unknown(Error?)

// MARK: - LocalizedError

public var errorDescription: String? {
switch self {
case .saveFailed:
"Failed to save contact"
case .fetchFailed:
"Failed to fetch contacts"
case .deleteFailed:
"Failed to delete contact"
case .updateFailed:
"Failed to update contact"
case .accessDenied:
"No access to contacts"
case .unknown:
"Contacts error"
}
}

public var failureReason: String? {
switch self {
case .saveFailed:
"The contact could not be saved to the address book."
case .fetchFailed:
"The contacts could not be retrieved from the address book."
case .deleteFailed:
"The contact could not be deleted from the address book."
case .updateFailed:
"The contact could not be updated in the address book."
case .accessDenied:
"Contacts access is restricted or denied."
case let .unknown(error):
error?.localizedDescription ?? "An unknown contacts error occurred."
}
}

public var recoverySuggestion: String? {
switch self {
case .saveFailed:
"Check if the contact data is valid and try again."
case .fetchFailed:
"Refresh the contacts and try again."
case .deleteFailed:
"Make sure the contact exists and try again."
case .updateFailed:
"Make sure the contact exists and try again."
case .accessDenied:
"Allow contacts access in Settings and try again."
case .unknown:
"Please try again later."
}
}

// MARK: - Deprecated Aliases

@available(*, deprecated, renamed: "accessDenied")
public static var notAccess: ContactsError {
.accessDenied
}
}
30 changes: 30 additions & 0 deletions Sources/OversizeCore/Error/CustomError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright © 2025 Alexander Romanov
// CustomError.swift, created on 01.02.2025
//

import Foundation

public struct CustomError: Error, LocalizedError, Sendable {
public let title: String
public let detail: String?
public let suggestion: String?

public init(title: String, detail: String? = nil, suggestion: String? = nil) {
self.title = title
self.detail = detail
self.suggestion = suggestion
}

public var errorDescription: String? {
title
}

public var failureReason: String? {
detail
}

public var recoverySuggestion: String? {
suggestion
}
}
62 changes: 62 additions & 0 deletions Sources/OversizeCore/Error/Deprecated.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// Copyright © 2025 Alexander Romanov
// Deprecated.swift, created on 02.02.2025
//

import Foundation

// MARK: - Deprecated Type Aliases

@available(*, deprecated, renamed: "PersistenceError")
public typealias CoreDataError = PersistenceError

@available(*, deprecated, renamed: "PersistenceError")
public typealias SwiftDataError = PersistenceError

@available(*, deprecated, renamed: "FileError")
public typealias FileManagerError = FileError

@available(*, deprecated, renamed: "CloudError")
public typealias CloudDocumentsError = CloudError

@available(*, deprecated, renamed: "CloudError")
public typealias CloudKitError = CloudError

@available(*, deprecated, renamed: "CalendarError")
public typealias EventKitError = CalendarError

@available(*, deprecated, renamed: "HealthError")
public typealias HealthKitError = HealthError

@available(*, deprecated, message: "Use FileError or CloudError instead")
public enum FileSyncError: Error, LocalizedError, Sendable {
case file(FileError)
case cloud(CloudError)

public var errorDescription: String? {
switch self {
case let .file(error):
error.errorDescription
case let .cloud(error):
error.errorDescription
}
}

public var failureReason: String? {
switch self {
case let .file(error):
error.failureReason
case let .cloud(error):
error.failureReason
}
}

public var recoverySuggestion: String? {
switch self {
case let .file(error):
error.recoverySuggestion
case let .cloud(error):
error.recoverySuggestion
}
}
}
Loading