From 7316cb9d92bd193555d2206a3a0e12edc634020f Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Mon, 8 Jan 2018 14:46:29 +0100 Subject: [PATCH] fixed panic when io is not available for export block, closes #7486 (#7495) --- parity/blockchain.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/parity/blockchain.rs b/parity/blockchain.rs index b1bf8d4dbb6..84a610ef3ef 100644 --- a/parity/blockchain.rs +++ b/parity/blockchain.rs @@ -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(); match format { - DataFormat::Binary => { out.write(&b).expect("Couldn't write to stream."); } - DataFormat::Hex => { out.write_fmt(format_args!("{}", b.pretty())).expect("Couldn't write to stream."); } + DataFormat::Binary => { + 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))?; + } } }