Files
NetNewsWire/iOS/ErrorHandler.swift
T

32 lines
768 B
Swift
Raw Normal View History

//
// ErrorHandler.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 5/26/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import UIKit
2025-10-02 08:54:48 -07:00
import os
import RSCore
struct ErrorHandler: Sendable {
2025-10-02 08:54:48 -07:00
private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "ErrorHandler")
2026-01-02 15:58:36 -08:00
@Sendable public static func present(_ viewController: UIViewController) -> @Sendable (Error) -> Void {
2019-06-27 14:21:07 -05:00
return { [weak viewController] error in
2025-11-17 14:25:56 -08:00
Task { @MainActor in
if UIApplication.shared.applicationState == .active {
viewController?.presentError(error)
} else {
log(error)
}
}
2019-06-27 14:21:07 -05:00
}
}
2025-11-17 14:25:56 -08:00
@Sendable nonisolated public static func log(_ error: Error) {
2025-10-02 08:54:48 -07:00
logger.error("\(error.localizedDescription)")
}
}