From 6ccaef91a17ce5cb1f7bc49c583f06c9f2cdb93b Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Fri, 6 Mar 2020 11:36:04 -0500 Subject: [PATCH] Add more informative messages --- .../Components/Window/WindowController.swift | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Persephone/Components/Window/WindowController.swift b/Persephone/Components/Window/WindowController.swift index 0b321a9..349cde7 100644 --- a/Persephone/Components/Window/WindowController.swift +++ b/Persephone/Components/Window/WindowController.swift @@ -164,19 +164,34 @@ class WindowController: NSWindowController { else { return } DispatchQueue.main.async { + guard let window = NSApplication.shared.mainWindow ?? self.window + else { return } + let alert = NSAlert(error: error) alert.messageText = error.message alert.alertStyle = error.recovered ? .warning : .critical + print(error.mpdError) + + switch error.mpdError { + case MPD_ERROR_MALFORMED, + MPD_ERROR_ARGUMENT: + alert.informativeText = "Please check the mpd log for more details." + case MPD_ERROR_SYSTEM, + MPD_ERROR_TIMEOUT: + alert.informativeText = "Is the mpd server running?" + case MPD_ERROR_RESOLVER: + alert.informativeText = "Check your network connection." + default: + break; + } + if !error.recovered { alert.addButton(withTitle: "Reconnect") alert.addButton(withTitle: "Dismiss") } - guard let window = NSApplication.shared.mainWindow ?? self.window - else { return } - alert.beginSheetModal(for: window) { response in switch response { case .alertFirstButtonReturn: