(self, context: &str)
| 122 | |
| 123 | impl<T> BTreeResultExt<T> for Result<T, BPlusTreeError> { |
| 124 | fn with_context(self, context: &str) -> BTreeResult<T> { |
| 125 | self.map_err(|e| match e { |
| 126 | BPlusTreeError::KeyNotFound => BPlusTreeError::KeyNotFound, |
| 127 | BPlusTreeError::InvalidCapacity(msg) => { |
| 128 | BPlusTreeError::InvalidCapacity(format!("{}: {}", context, msg)) |
| 129 | } |
| 130 | BPlusTreeError::DataIntegrityError(msg) => { |
| 131 | BPlusTreeError::data_integrity(context, &msg) |
| 132 | } |
| 133 | BPlusTreeError::ArenaError(msg) => BPlusTreeError::arena_error(context, &msg), |
| 134 | BPlusTreeError::NodeError(msg) => { |
| 135 | BPlusTreeError::NodeError(format!("{}: {}", context, msg)) |
| 136 | } |
| 137 | BPlusTreeError::CorruptedTree(msg) => BPlusTreeError::corrupted_tree(context, &msg), |
| 138 | BPlusTreeError::InvalidState(msg) => BPlusTreeError::invalid_state(context, &msg), |
| 139 | BPlusTreeError::AllocationError(msg) => BPlusTreeError::allocation_error(context, &msg), |
| 140 | }) |
| 141 | } |
| 142 | |
| 143 | fn with_operation(self, operation: &str) -> BTreeResult<T> { |
| 144 | self.with_context(&format!("Operation '{}'", operation)) |
no outgoing calls