1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-08 04:20:07 +02:00

👌 Handle errors

This commit is contained in:
2022-02-18 20:38:40 +01:00
parent 0e8fe1fcfb
commit dd43c94e6e
2 changed files with 8 additions and 2 deletions

View File

@ -56,7 +56,10 @@ class InterApp {
if PhpEnv.shared.availablePhpVersions.contains(version) { if PhpEnv.shared.availablePhpVersions.contains(version) {
MainMenu.shared.switchToPhpVersion(version) MainMenu.shared.switchToPhpVersion(version)
} else { } else {
Alert.notify(message: "Unsupported version", info: "PHP Monitor can't switch to PHP \(version), as it may not be installed or available.") BetterAlert().withInformation(
title: "Unsupported version",
subtitle: "PHP Monitor can't switch to PHP \(version), as it may not be installed or available."
).withPrimary(text: "OK").show()
} }
}), }),
]} ]}

View File

@ -85,7 +85,10 @@ class BetterAlert {
If you wish to simply show the alert and disregard the outcome, use `show`. If you wish to simply show the alert and disregard the outcome, use `show`.
*/ */
public func runModal() -> NSApplication.ModalResponse { public func runModal() -> NSApplication.ModalResponse {
#warning("You should be alerted if this is not being called on the main thread.") if !Thread.isMainThread {
fatalError("You should always present alerts on the main thread!")
}
NSApp.activate(ignoringOtherApps: true) NSApp.activate(ignoringOtherApps: true)
windowController.window?.makeKeyAndOrderFront(nil) windowController.window?.makeKeyAndOrderFront(nil)
return NSApplication.shared.runModal(for: windowController.window!) return NSApplication.shared.runModal(for: windowController.window!)