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.
This commit is contained in:
Stefan Ceriu
2026-06-22 14:18:45 +03:00
parent c5653c2208
commit b4fe69a0c9
@@ -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)")
}
}