turn panic into an error with more details

This commit is contained in:
Dmitry Rodionov
2022-05-03 12:00:42 +03:00
committed by Dmitry Rodionov
parent 9ede38b6c4
commit ff7e9a86c6

View File

@@ -1504,12 +1504,20 @@ impl LayeredTimeline {
let ancestor = self
.ancestor_timeline
.as_ref()
.expect("there should be an ancestor")
.with_context(|| {
format!(
"Ancestor is missing. Timeline id: {} Ancestor id {:?}",
self.timelineid,
self.get_ancestor_timeline_id(),
)
})?
.ensure_loaded()
.with_context(|| {
format!(
"Cannot get the whole layer for read locked: timeline {} is not present locally",
self.get_ancestor_timeline_id().unwrap())
"Ancestor timeline is not is not loaded. Timeline id: {} Ancestor id {:?}",
self.timelineid,
self.get_ancestor_timeline_id(),
)
})?;
Ok(Arc::clone(ancestor))
}