Skip to content

Commit bc7df5f

Browse files
committed
refactor: improving some error messages
1 parent 6e62c8a commit bc7df5f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/terminal/app.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,17 +292,26 @@ fn spawn_key_event_listener(&self) {
292292
return Ok(());
293293
}
294294

295-
let status = Command::new("systemctl")
295+
let mut cmd = Command::new("systemctl");
296+
297+
cmd
296298
.arg("edit")
297-
.arg("--full")
299+
.arg("--full");
300+
301+
if self.selected_tab_index==1{
302+
cmd
303+
.arg("--user");
304+
}
305+
306+
let status = cmd
298307
.arg(unit_name)
299308
.status();
300309

301310
match status {
302311
Ok(s) if s.success() => {},
303-
Ok(s) => {
312+
Ok(_s) => {
304313
self.resume_tui(terminal)?;
305-
self.error_popup(terminal, format!("systemctl edit failed with status: {}", s))?;
314+
self.error_popup(terminal, format!("'systemctl edit' failed. Try running the program with sudo!"))?;
306315
},
307316
Err(e) => {
308317
self.resume_tui(terminal)?;
@@ -621,7 +630,7 @@ fn spawn_key_event_listener(&self) {
621630
.borrow_mut()
622631
.change_repository_connection(conn_type)
623632
{
624-
self.event_tx.send(AppEvent::Error("Failed to change connection type with D-Bus, try run without sudo".to_string())).expect("Failed to change connection type");
633+
self.event_tx.send(AppEvent::Error("Failed to change connection type with D-Bus. Try run without sudo".to_string())).expect("Failed to change connection type");
625634
self.selected_tab_index = 0;
626635
return
627636
}

0 commit comments

Comments
 (0)