Skip to content

Commit

Permalink
Fix #60 - print the error when a command fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars T Hansen committed Jul 24, 2023
1 parent 32c2ae4 commit 2e07a88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn main() {
}
}

fn log(msg: &str) {
fn log_cmderror(msg: &str, err: command::CmdError) {
// TODO (issue 52): Implement some sensible logging maybe
eprintln!("SONAR ERROR: {:?}", msg);
eprintln!("SONAR ERROR: {:?}\n{:?}", msg, err);
}
10 changes: 5 additions & 5 deletions src/ps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::amd;
use crate::command::CmdError;
use crate::jobs;
use crate::log;
use crate::log_cmderror;
use crate::nvidia;
use crate::process;
use crate::util::{three_places, time_iso8601};
Expand Down Expand Up @@ -170,8 +170,8 @@ fn add_gpu_info(
);
}
}
Err(_) => {
log("GPU process listing failed");
Err(e) => {
log_cmderror("GPU process listing failed", e);
}
}
}
Expand Down Expand Up @@ -221,8 +221,8 @@ pub fn create_snapshot(
let mut user_by_pid: HashMap<usize, String> = HashMap::new();

match process::get_process_information(jobs) {
Err(_e) => {
log("CPU process listing failed");
Err(e) => {
log_cmderror("CPU process listing failed", e);
return;
}
Ok(ps_output) => {
Expand Down

0 comments on commit 2e07a88

Please sign in to comment.