Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cob: Return error on wrong history type
Alexis Sellier committed 3 years ago
commit 4e0efa4690c5486d918f615763dda1dd8b022090
parent 81a1ee5cc24d92987749716a692cc65da81f66fb
1 file changed +4 -1
modified radicle/src/cob/store.rs
@@ -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)