mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
cli: improve dbus error messaging on linux
Fixes https://github.com/microsoft/vscode-remote-release/issues/7778
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user