Skip to content

Commit

Permalink
Improve error output
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Aug 4, 2023
1 parent a615395 commit ffcddb0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rx-repack"
description = "Rust re-write of px-repack"
version = "0.4.0"
version = "0.4.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::Context;
use camino::Utf8PathBuf;
use clap::Parser;
use rx_repack::{json_message, repack};
Expand Down Expand Up @@ -65,5 +66,7 @@ fn main() -> anyhow::Result<()> {
println!("{}", json_message(&dicom_file, &outcome)?);
}

outcome.map(|_| ())
outcome
.with_context(|| format!("Failed to pack: {}", &dicom_file))
.map(|_| ())
}
4 changes: 2 additions & 2 deletions src/ndjson_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use std::os::unix::fs::MetadataExt;
pub fn json_message(
src: &Utf8Path,
result: &anyhow::Result<RepackOutcome>,
) -> anyhow::Result<String> {
) -> serde_json::Result<String> {
let msg = Message::new(src, result);
serde_json::to_string(&msg).map_err(anyhow::Error::from)
serde_json::to_string(&msg)
}

#[allow(non_snake_case)]
Expand Down

0 comments on commit ffcddb0

Please sign in to comment.