mirror of
https://github.com/sharkdp/hyperfine.git
synced 2024-12-02 16:33:48 +03:00
Proper error handling for the exporter
This commit is contained in:
parent
9b5dd60a92
commit
1bd5436109
@ -13,14 +13,7 @@ pub struct JsonExporter {}
|
|||||||
|
|
||||||
impl Exporter for JsonExporter {
|
impl Exporter for JsonExporter {
|
||||||
fn serialize(&self, results: &Vec<ExportEntry>) -> Result<String> {
|
fn serialize(&self, results: &Vec<ExportEntry>) -> Result<String> {
|
||||||
let serialized = to_string_pretty(&HyperfineSummary { results });
|
to_string_pretty(&HyperfineSummary { results }).map_err(|e| Error::new(ErrorKind::Other, e))
|
||||||
|
|
||||||
serialized.map_err(|e| {
|
|
||||||
Error::new(
|
|
||||||
ErrorKind::Other,
|
|
||||||
format!("Error while serializing to JSON: {:}", e),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,13 @@ fn main() {
|
|||||||
|
|
||||||
match res {
|
match res {
|
||||||
Ok(timing_results) => {
|
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()),
|
Err(e) => error(e.description()),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user