Skip to content
This repository was archived by the owner on Oct 23, 2022. It is now read-only.

Commit eb005bb

Browse files
committed
refactor(http): widen write error variant
1 parent 328d2ab commit eb005bb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

http/src/config.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub enum InitializationError {
5151
#[error("key encoding failed: {0}")]
5252
PrivateKeyEncodingFailed(prost::EncodeError),
5353
#[error("config serialization failed: {0}")]
54-
ConfigWritingFailed(serde_json::Error),
54+
ConfigWritingFailed(Box<dyn std::error::Error + 'static>),
5555
}
5656

5757
/// Creates the IPFS_PATH directory structure and creates a new compatible configuration file with
@@ -146,9 +146,11 @@ pub fn init(
146146
let mut writer = BufWriter::new(config_file);
147147

148148
serde_json::to_writer_pretty(&mut writer, &config_contents)
149-
.map_err(InitializationError::ConfigWritingFailed)?;
149+
.map_err(|e| InitializationError::ConfigWritingFailed(Box::new(e)))?;
150150

151-
writer.flush().unwrap();
151+
writer
152+
.flush()
153+
.map_err(|e| InitializationError::ConfigWritingFailed(Box::new(e)))?;
152154

153155
Ok(peer_id)
154156
}

0 commit comments

Comments
 (0)