mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
🏗 Keep track of Homebrew error log
This commit is contained in:
@ -45,4 +45,5 @@ struct BrewCommandProgress {
|
||||
|
||||
struct BrewCommandError: Error {
|
||||
let error: String
|
||||
let log: [String]
|
||||
}
|
||||
|
@ -109,11 +109,14 @@ class InstallAndUpgradeCommand: BrewCommand {
|
||||
}
|
||||
|
||||
private func run(_ command: String, _ onProgress: @escaping (BrewCommandProgress) -> Void) async throws {
|
||||
var loggedMessages: [String] = []
|
||||
|
||||
let (process, _) = try! await Shell.attach(
|
||||
command,
|
||||
didReceiveOutput: { text, _ in
|
||||
if !text.isEmpty {
|
||||
Log.perf(text)
|
||||
loggedMessages.append(text)
|
||||
}
|
||||
|
||||
if let (number, text) = self.reportInstallationProgress(text) {
|
||||
@ -124,9 +127,10 @@ class InstallAndUpgradeCommand: BrewCommand {
|
||||
)
|
||||
|
||||
if process.terminationStatus <= 0 {
|
||||
loggedMessages = []
|
||||
return
|
||||
} else {
|
||||
throw BrewCommandError(error: "The command failed to run correctly.")
|
||||
throw BrewCommandError(error: "The command failed to run correctly.", log: loggedMessages)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,14 @@ class RemovePhpVersionCommand: BrewCommand {
|
||||
return
|
||||
}
|
||||
|
||||
var loggedMessages: [String] = []
|
||||
|
||||
let (process, _) = try! await Shell.attach(
|
||||
command,
|
||||
didReceiveOutput: { text, _ in
|
||||
if !text.isEmpty {
|
||||
Log.perf(text)
|
||||
loggedMessages.append(text)
|
||||
}
|
||||
},
|
||||
withTimeout: .minutes(5)
|
||||
@ -56,7 +59,7 @@ class RemovePhpVersionCommand: BrewCommand {
|
||||
await MainMenu.shared.refreshActiveInstallation()
|
||||
onProgress(.create(value: 1, title: progressTitle, description: "The operation has succeeded."))
|
||||
} else {
|
||||
throw BrewCommandError(error: "The command failed to run correctly.")
|
||||
throw BrewCommandError(error: "The command failed to run correctly.", log: loggedMessages)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -197,11 +197,14 @@ struct PhpFormulaeView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
} catch let error {
|
||||
let error = error as! BrewCommandError
|
||||
let messages = error.log.suffix(5).joined(separator: "\n")
|
||||
|
||||
self.setBusyStatus(false)
|
||||
self.presentErrorAlert(
|
||||
title: "phpman.failures.install.title".localized,
|
||||
description: "phpman.failures.install.desc".localized,
|
||||
description: "phpman.failures.install.desc".localized(messages),
|
||||
button: "generic.ok".localized
|
||||
)
|
||||
}
|
||||
|
@ -120,7 +120,9 @@ You may be asked for your password during the uninstallation process if file per
|
||||
"phpman.warnings.removal.button" = "Uninstall";
|
||||
|
||||
"phpman.failures.install.title" = "Installation failed!";
|
||||
"phpman.failures.install.desc" = "Unfortunately, the automatic installation failed. PHP Monitor can only do so much and it's always possible that installations can fail for some unknown reason. At this point I'd recommend checking out the README to find out how to manually install a given PHP version via the Terminal. Remember to restart PHP Monitor (or press the refresh button) when this is done.";
|
||||
"phpman.failures.install.desc" = "Unfortunately, the installation or upgrade failed for some reason. I can't do much about this, but I will show you the last messages that were returned by Homebrew:
|
||||
|
||||
%@";
|
||||
|
||||
"phpman.uninstall_prevented.title" = "You cannot uninstall the currently active version of PHP via PHP Monitor.";
|
||||
"phpman.uninstall_prevented.desc" = "In order to prevent issues with PHP Monitor and further crashes, it isn't possible to uninstall the currently linked version of PHP via this UI. You can switch versions and try again, or uninstall this version manually via the terminal.\n\nPlease note that PHP Monitor may crash if you uninstall the currently linked PHP version.";
|
||||
|
Reference in New Issue
Block a user