cli: improve dbus error messaging on linux

Fixes https://github.com/microsoft/vscode-remote-release/issues/7778
This commit is contained in:
Connor Peet
2023-06-16 14:01:07 -07:00
parent 95e90d22ec
commit 8a006c7114
2 changed files with 28 additions and 3 deletions

View File

@@ -442,6 +442,26 @@ macro_rules! makeAnyError {
};
}
#[derive(Debug)]
pub struct DbusConnectFailedError(pub String);
impl Display for DbusConnectFailedError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let mut str = String::new();
str.push_str("Error creating dbus session. This command uses systemd for managing services, you should check that systemd is installed and under your user.");
if std::env::var("WSL_DISTRO_NAME").is_ok() {
str.push_str("\n\nTo enable systemd on WSL, check out: https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/.\n\n");
}
str.push_str("If running `systemctl status` works, systemd is ok, but your session dbus may not be. You might need to:\n\n- Install the `dbus-user-session` package, and reboot if it was not installed\n- Start the user dbus session with `systemctl --user enable dbus --now`.\n\nThe error encountered was: ");
str.push_str(&self.0);
str.push('\n');
write!(f, "{}", str)
}
}
/// Internal errors in the VS Code CLI.
/// Note: other error should be migrated to this type gradually
#[derive(Error, Debug)]
@@ -522,7 +542,8 @@ makeAnyError!(
MissingHomeDirectory,
OAuthError,
InvalidRpcDataError,
CodeError
CodeError,
DbusConnectFailedError
);
impl From<reqwest::Error> for AnyError {