diff --git a/src/hyperfine/export/json.rs b/src/hyperfine/export/json.rs index e4e6631..39ff4fb 100644 --- a/src/hyperfine/export/json.rs +++ b/src/hyperfine/export/json.rs @@ -13,14 +13,7 @@ pub struct JsonExporter {} impl Exporter for JsonExporter { fn serialize(&self, results: &Vec) -> Result { - let serialized = to_string_pretty(&HyperfineSummary { results }); - - serialized.map_err(|e| { - Error::new( - ErrorKind::Other, - format!("Error while serializing to JSON: {:}", e), - ) - }) + to_string_pretty(&HyperfineSummary { results }).map_err(|e| Error::new(ErrorKind::Other, e)) } } diff --git a/src/main.rs b/src/main.rs index 339e2eb..32253df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -207,7 +207,13 @@ fn main() { match res { Ok(timing_results) => { - export_manager.write_results(timing_results).unwrap(); + let ans = export_manager.write_results(timing_results); + if let Err(e) = ans { + error(&format!( + "The following error occured while exporting: {}", + e.description() + )); + } } Err(e) => error(e.description()), }