2019-05-26 18:54:32 +02:00
|
|
|
//
|
|
|
|
// ErrorHandler.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 5/26/19.
|
|
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import AppKit
|
|
|
|
import Account
|
2019-06-10 22:21:17 +02:00
|
|
|
import os.log
|
2019-05-26 18:54:32 +02:00
|
|
|
|
2024-03-22 18:11:40 +01:00
|
|
|
// asserts that OSLog is a sendable type
|
|
|
|
// @preconcurrency import os.log _should_ resolve the warning in this scenario, but does
|
|
|
|
// not due to a bug (in Swift 5.10)
|
2024-03-22 19:35:04 +01:00
|
|
|
#if swift(>=6.0)
|
|
|
|
#warning("Reevaluate whether this Sendable decoration is still needed for OSLog.")
|
|
|
|
#endif
|
2024-03-22 18:11:40 +01:00
|
|
|
extension OSLog: @unchecked Sendable { }
|
|
|
|
|
2019-05-26 18:54:32 +02:00
|
|
|
struct ErrorHandler {
|
|
|
|
|
2024-03-20 07:05:30 +01:00
|
|
|
private static let log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Account")
|
|
|
|
|
|
|
|
@MainActor public static func present(_ error: Error) {
|
2019-05-26 18:54:32 +02:00
|
|
|
NSApplication.shared.presentError(error)
|
|
|
|
}
|
|
|
|
|
2019-06-10 22:21:17 +02:00
|
|
|
public static func log(_ error: Error) {
|
2024-03-20 07:05:30 +01:00
|
|
|
os_log(.error, log: log, "%@", error.localizedDescription)
|
2019-06-10 22:21:17 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 18:54:32 +02:00
|
|
|
}
|