fixed panic when io is not available for export block, closes #7486 (#7495)

This commit is contained in:
Marek Kotewicz 2018-01-08 14:46:29 +01:00 committed by Tomasz Drwięga
parent 33b8f28f62
commit 7316cb9d92

View File

@ -591,8 +591,12 @@ fn execute_export(cmd: ExportBlockchain) -> Result<(), String> {
} }
let b = client.block(BlockId::Number(i)).ok_or("Error exporting incomplete chain")?.into_inner(); let b = client.block(BlockId::Number(i)).ok_or("Error exporting incomplete chain")?.into_inner();
match format { match format {
DataFormat::Binary => { out.write(&b).expect("Couldn't write to stream."); } DataFormat::Binary => {
DataFormat::Hex => { out.write_fmt(format_args!("{}", b.pretty())).expect("Couldn't write to stream."); } out.write(&b).map_err(|e| format!("Couldn't write to stream. Cause: {}", e))?;
}
DataFormat::Hex => {
out.write_fmt(format_args!("{}", b.pretty())).map_err(|e| format!("Couldn't write to stream. Cause: {}", e))?;
}
} }
} }