Skip to content

Commit

Permalink
improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
magiclen committed Nov 13, 2023
1 parent 395be0a commit b7a9bda
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ffmpeg-screen-recorder"
version = "1.0.20"
version = "1.0.21"
authors = ["Magic Len <[email protected]>"]
edition = "2021"
rust-version = "1.70"
Expand Down
6 changes: 5 additions & 1 deletion src/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ impl Resolution {
&mut command4,
&mut command5,
])
.with_context(|| anyhow!("xrandr"))?;
.with_context(|| {
anyhow!(
"{command1:?} | {command2:?} | {command3:?} | {command4:?} | {command5:?}"
)
})?;

let res = unsafe { String::from_utf8_unchecked(res_output.stdout) };

Expand Down
14 changes: 10 additions & 4 deletions src/window_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl WindowInfo {

command.stdout(Stdio::piped());

let output = command.execute_output().with_context(|| anyhow!("xwininfo"))?;
let output = command.execute_output().with_context(|| anyhow!("{command:?}"))?;

if output.status.code().is_none() {
process::exit(1);
Expand All @@ -41,7 +41,10 @@ impl WindowInfo {
let output = command1
.execute_multiple_input_output(win_info.as_slice(), &mut [&mut command2, &mut command3])
.with_context(|| {
anyhow!("grep 'Width:' from {:?}", String::from_utf8_lossy(win_info.as_slice()))
anyhow!(
"{command1:?} | {command2:?} | {command3:?} | from {:?}",
String::from_utf8_lossy(win_info.as_slice())
)
})?;

let win_width: i32 = unsafe { from_utf8_unchecked(output.stdout.as_slice()) }
Expand All @@ -54,7 +57,10 @@ impl WindowInfo {
let output = command1
.execute_multiple_input_output(win_info.as_slice(), &mut [&mut command2, &mut command3])
.with_context(|| {
anyhow!("grep 'Height:' from {:?}", String::from_utf8_lossy(win_info.as_slice()))
anyhow!(
"{command1:?} | {command2:?} | {command3:?} | from {:?}",
String::from_utf8_lossy(win_info.as_slice())
)
})?;

let win_height: i32 =
Expand All @@ -66,7 +72,7 @@ impl WindowInfo {
.execute_multiple_input_output(win_info.as_slice(), &mut [&mut command2, &mut command3])
.with_context(|| {
anyhow!(
"grep 'Absolute upper-left X' from {:?}",
"{command1:?} | {command2:?} | {command3:?} | from {:?}",
String::from_utf8_lossy(win_info.as_slice())
)
})?;
Expand Down

0 comments on commit b7a9bda

Please sign in to comment.