From 44fc11dff88fe8dfc2e323d989e26d6cbd19f961 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Wed, 17 Jan 2024 13:27:31 +0100 Subject: [PATCH] cob: Don't panic on missing root This can happen if the change was not able to be loaded due to open file limit issues for example. --- radicle-cob/src/change_graph.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/radicle-cob/src/change_graph.rs b/radicle-cob/src/change_graph.rs index 32f195ca..b8fe201e 100644 --- a/radicle-cob/src/change_graph.rs +++ b/radicle-cob/src/change_graph.rs @@ -17,6 +17,8 @@ pub enum EvaluateError { Init(Box), #[error("invalid signature for entry '{0}'")] Signature(EntryId), + #[error("root entry '{0}' missing from graph")] + MissingRoot(EntryId), } /// The graph of changes for a particular collaborative object @@ -100,7 +102,7 @@ impl ChangeGraph { let root = self .graph .get(&root) - .expect("ChangeGraph::evaluate: root must be part of change graph"); + .ok_or(EvaluateError::MissingRoot(root))?; if !root.valid_signatures() { return Err(EvaluateError::Signature(root.id));