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:
@@ -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}"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user