From d63ce337af2e56ea09b5cd9b63c5d2315793af6e Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 25 Jul 2026 21:59:14 -0700 Subject: [PATCH] Drop recovery suggestions with no recovery options. --- Mac/ErrorHandler.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Mac/ErrorHandler.swift b/Mac/ErrorHandler.swift index 1a7d84502..8381d6c1b 100644 --- a/Mac/ErrorHandler.swift +++ b/Mac/ErrorHandler.swift @@ -16,11 +16,23 @@ struct ErrorHandler: Sendable { @Sendable public static func present(_ error: Error) { Task { @MainActor in - NSApplication.shared.presentError(error) + NSApplication.shared.presentError(errorForPresentation(error)) } } public static func log(_ error: Error) { logger.error("\(error.localizedDescription)") } + + // Drop a recovery suggestion when there are no recovery options to act on it. + private static func errorForPresentation(_ error: Error) -> NSError { + let nsError = error as NSError + guard nsError.localizedRecoverySuggestion != nil, nsError.localizedRecoveryOptions == nil else { + return nsError + } + var userInfo = nsError.userInfo + userInfo[NSLocalizedDescriptionKey] = nsError.localizedDescription + userInfo[NSLocalizedRecoverySuggestionErrorKey] = nil + return NSError(domain: nsError.domain, code: nsError.code, userInfo: userInfo) + } }