Skip to content
Myr

Proper error handling for the exporter

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by David Peter · parent 9b5dd60 · Browse files · 2 files+8 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+8 added−9 removed

  • other:+8 added−9 removed

2 files+8 added−9 removed

modified:src/hyperfine/export/json.rs+1 added-8 removed
11 unmodified lines
12pub struct JsonExporter {}1314impl Exporter for JsonExporter {15 fn serialize(&self, results: &Vec<ExportEntry>) -> Result<String> {16 let serialized = to_string_pretty(&HyperfineSummary { results });1718 serialized.map_err(|e| {19 Error::new(20 ErrorKind::Other,21 format!("Error while serializing to JSON: {:}", e),22 )23 })16 to_string_pretty(&HyperfineSummary { results }).map_err(|e| Error::new(ErrorKind::Other, e))17 }18}1920impl JsonExporter {
4 unmodified lines
modified:src/main.rs+7 added-1 removed
205 unmodified lines
206 let res = run(&commands, &options);207208 match res {209 Ok(timing_results) => {210 export_manager.write_results(timing_results).unwrap();210 let ans = export_manager.write_results(timing_results);211 if let Err(e) = ans {212 error(&format!(213 "The following error occured while exporting: {}",214 e.description()215 ));216 }217 }218 Err(e) => error(e.description()),219 }220}