mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-28 21:50:26 +08:00
cob: Return error on wrong history type
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
@@ -44,6 +44,8 @@ pub enum Error {
|
||||
Identity(#[from] project::IdentityError),
|
||||
#[error(transparent)]
|
||||
Serialize(#[from] serde_json::Error),
|
||||
#[error("unexpected history type '{0}'")]
|
||||
HistoryType(String),
|
||||
#[error("object `{1}` of type `{0}` was not found")]
|
||||
NotFound(TypeName, ObjectId),
|
||||
}
|
||||
@@ -147,9 +149,10 @@ where
|
||||
|
||||
if let Some(cob) = cob {
|
||||
if cob.manifest().history_type != HISTORY_TYPE {
|
||||
panic!();
|
||||
return Err(Error::HistoryType(cob.manifest().history_type.clone()));
|
||||
}
|
||||
let (obj, clock) = T::from_history(cob.history())?;
|
||||
|
||||
Ok(Some((obj, clock)))
|
||||
} else {
|
||||
Ok(None)
|
||||
|
||||
Reference in New Issue
Block a user