refactor: reduce map_err boilerplate with context helper methods (TODO-025)

Add per-crate variant_ctx() helper methods to StorageError, BlobCacheError,
ProtocolError, and BridgeError. Replace 78 .map_err(|e| format!(...))
closures with concise context calls. Identical error messages preserved.
This commit is contained in:
Edison Jwa
2026-06-11 12:25:00 +09:00
parent 1efeaac19d
commit 40883c40c8
4 changed files with 89 additions and 49 deletions
+10
View File
@@ -120,3 +120,13 @@ pub enum ProtocolError {
#[error("file transfer failed: {0}")]
FileTransfer(String),
}
impl ProtocolError {
fn lost(msg: impl Into<String>) -> Self {
ProtocolError::Lost(msg.into())
}
fn backend_ctx(ctx: impl std::fmt::Display, e: impl std::fmt::Display) -> Self {
ProtocolError::Backend(format!("{ctx}: {e}"))
}
}