From b4fe69a0c931b661917ab46e9f2b45f994e835d5 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Mon, 22 Jun 2026 14:18:45 +0300 Subject: [PATCH] Don't crash when the tone manager directories can't be created NotificationToneManager.init force-crashed (fatalError) when createDirectory failed, e.g. a sandbox permission error (NSCocoaError 513). Log the error instead of killing the app. The underlying cause is acknowledged and will be treated separately. --- .../Services/AlertTones/NotificationToneManager.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ElementX/Sources/Services/AlertTones/NotificationToneManager.swift b/ElementX/Sources/Services/AlertTones/NotificationToneManager.swift index 5e464b898..cd19d0a28 100644 --- a/ElementX/Sources/Services/AlertTones/NotificationToneManager.swift +++ b/ElementX/Sources/Services/AlertTones/NotificationToneManager.swift @@ -54,7 +54,10 @@ nonisolated struct NotificationToneManager: NotificationToneManagerProtocol { try FileManager.default.createDirectory(at: NotificationToneManager.libraryLocation, withIntermediateDirectories: true) try FileManager.default.createDirectory(at: Self.selectedToneLocation.deletingLastPathComponent(), withIntermediateDirectories: true) } catch { - fatalError("Catastrophic error setting up tone manager: \(error)") + // Don't crash on a recoverable file system error. The underlying problem (directory creation + // failing on launch, e.g. a background launch before the container is writable) is acknowledged + // and will be treated separately. + MXLog.error("Failed setting up tone manager directories: \(error)") } }