1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00

Add more informative messages

This commit is contained in:
Daniel Barber 2020-03-06 11:36:04 -05:00
parent c4e5f7408a
commit 6ccaef91a1
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8

View File

@ -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: