mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-10 05:00:06 +02:00
👌 Better alerts for error state
This commit is contained in:
@@ -116,46 +116,46 @@ class ValetServicesManager: ServicesManager {
|
|||||||
await ServicesManager.shared.reloadServicesStatus()
|
await ServicesManager.shared.reloadServicesStatus()
|
||||||
|
|
||||||
Task {
|
Task {
|
||||||
|
await presentTroubleshootingForService(named: named)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func presentTroubleshootingForService(named: String) {
|
@MainActor func presentTroubleshootingForService(named: String) {
|
||||||
Task { @MainActor in
|
let after = self.homebrewServices.first { service in
|
||||||
let after = self.homebrewServices.first { service in
|
return service.name == named
|
||||||
return service.name == named
|
}
|
||||||
|
|
||||||
|
guard let after else { return }
|
||||||
|
|
||||||
|
if after.status == "error" {
|
||||||
|
Log.err("The service '\(named)' is now reporting an error.")
|
||||||
|
|
||||||
|
guard let errorLogPath = after.error_log_path else {
|
||||||
|
return BetterAlert().withInformation(
|
||||||
|
title: "alert.service_error.title".localized(named),
|
||||||
|
subtitle: "alert.service_error.subtitle.no_error_log".localized(named),
|
||||||
|
description: "alert.service_error.extra".localized
|
||||||
|
)
|
||||||
|
.withPrimary(text: "alert.service_error.button.close".localized)
|
||||||
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let after else { return }
|
BetterAlert().withInformation(
|
||||||
|
title: "alert.service_error.title".localized(named),
|
||||||
if after.status == "error" {
|
subtitle: "alert.service_error.subtitle.error_log".localized(named),
|
||||||
Log.err("The service '\(named)' is now reporting an error.")
|
description: "alert.service_error.extra".localized
|
||||||
|
)
|
||||||
let hasErrorPath = after.error_log_path != nil
|
.withPrimary(text: "alert.service_error.button.close".localized)
|
||||||
|
.withTertiary(text: "alert.service_error.button.show_log".localized, action: { alert in
|
||||||
if hasErrorPath {
|
let url = URL(fileURLWithPath: errorLogPath)
|
||||||
BetterAlert().withInformation(
|
if errorLogPath.hasSuffix(".log") {
|
||||||
title: "alert.service_error.title".localized(named),
|
NSWorkspace.shared.open(url)
|
||||||
subtitle: "alert.service_error.subtitle.error_log".localized(named),
|
|
||||||
description: "alert.service_error.extra".localized
|
|
||||||
)
|
|
||||||
.withPrimary(text: "alert.service_error.button.close".localized)
|
|
||||||
.withSecondary(text: "alert.service_error.button.show_log", action: { alert in
|
|
||||||
let url = URL(fileURLWithPath: after.error_log_path!)
|
|
||||||
NSWorkspace.shared.activateFileViewerSelecting([url])
|
|
||||||
alert.close(with: .OK)
|
|
||||||
})
|
|
||||||
.show()
|
|
||||||
} else {
|
} else {
|
||||||
BetterAlert().withInformation(
|
NSWorkspace.shared.activateFileViewerSelecting([url])
|
||||||
title: "alert.service_error.title".localized(named),
|
|
||||||
subtitle: "alert.service_error.subtitle.no_error_log".localized(named),
|
|
||||||
description: "alert.service_error.extra".localized
|
|
||||||
)
|
|
||||||
.withPrimary(text: "alert.service_error.button.close".localized)
|
|
||||||
.show()
|
|
||||||
}
|
}
|
||||||
}
|
alert.close(with: .OK)
|
||||||
|
})
|
||||||
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user