Turning a panic into an error when making a patch

pmeunier
Jul 4, 2023, 10:41 AM
FMLTNQ4EYXA54OGII5AX2G2I7YFDVNMTOM7GDDTCKBTWGZPABH2AC

Dependencies

  • [2] ZDK3GNDB Tag transactions (including a massive refactoring of errors)
  • [3] UN2M77YU Test new changes against the old code. Fix several small bugs.
  • [4] 5FI6SBEZ Re-implement change printing and parsing
  • [5] YN63NUZO Sanakirja 1.0
  • [6] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [7] GHO6DWPI Refactoring iterators
  • [8] UNZXTNSJ Change text format: order dependencies in the order they were on the channel at record time
  • [9] I24UEJQL Various post-fire fixes
  • [10] CCFJ7VO3 Renaming "Record" to "Hunk" in the changes
  • [11] FXEDPLRI Resurrecting tests, and type cleanup (no need for Arc<RwLock<…>> anymore)
  • [12] VO5OQW4W Removing anyhow in libpijul
  • [13] I52XSRUH Massive cleanup, and simplification
  • [14] SMMBFECL Converting to the new patch format "online"
  • [15] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [16] NUAOEIXM Adding inode and byte to Local
  • [*] A3RM526Y Integrating identity malleability
  • [*] 73NW2X2M Returning a parse error instead of panicking when parsing a text change

Change contents

  • replacement in libpijul/src/record.rs at line 1379
    [3.615][3.615:646]()
    TxnErr<T::GraphError>,
    [3.615]
    [3.646]
    crate::change::MakeChangeError<T>,
  • replacement in libpijul/src/change.rs at line 211
    [3.835985][3.117887:117947]()
    ) -> Result<(Vec<Hash>, Vec<Hash>), TxnErr<T::DepsError>> {
    [3.835985]
    [3.836025]
    ) -> Result<(Vec<Hash>, Vec<Hash>), MakeChangeError<T>> {
  • replacement in libpijul/src/change.rs at line 292
    [3.838412][3.119096:119137]()
    ) -> Result<(), TxnErr<T::GraphError>> {
    [3.838412]
    [3.838416]
    ) -> Result<(), MakeChangeError<T>> {
  • replacement in libpijul/src/change.rs at line 301
    [3.838610][3.64147:64208]()
    let from = txn.find_block_end(channel, e_from).unwrap();
    [3.838610]
    [3.138571]
    let from = if let Ok(from) = txn.find_block_end(channel, e_from) {
    from
    } else {
    return Err(MakeChangeError::InvalidChange)
    };
  • replacement in libpijul/src/change.rs at line 331
    [3.839310][3.119501:119542]()
    ) -> Result<(), TxnErr<T::GraphError>> {
    [3.839310]
    [3.839314]
    ) -> Result<(), MakeChangeError<T>> {
  • replacement in libpijul/src/change.rs at line 340
    [3.839506][3.64209:64268]()
    let mut to = txn.find_block(channel, to_pos).unwrap();
    [3.839506]
    [3.839565]
    let mut to = if let Ok(to) = txn.find_block(channel, to_pos) {
    to
    } else {
    return Err(MakeChangeError::InvalidChange)
    };
  • edit in libpijul/src/change.rs at line 1319
    [3.867084]
    [18.41299]
    #[derive(Error)]
    pub enum MakeChangeError<T: GraphTxnT> {
    #[error(transparent)]
    Graph(#[from] TxnErr<<T as GraphTxnT>::GraphError>),
    #[error("Invalid change")]
    InvalidChange,
    }
    impl<T: GraphTxnT> std::fmt::Debug for MakeChangeError<T> {
    fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
    match self {
    MakeChangeError::Graph(e) => std::fmt::Debug::fmt(e, fmt),
    MakeChangeError::InvalidChange => std::fmt::Debug::fmt("InvalidChange", fmt),
    }
    }
    }
  • replacement in libpijul/src/change.rs at line 1346
    [3.867387][3.122599:122645]()
    ) -> Result<Self, TxnErr<T::DepsError>> {
    [3.867387]
    [3.105473]
    ) -> Result<Self, MakeChangeError<T>> {
  • edit in libpijul/src/change/text_changes.rs at line 22
    [19.127]
    [3.38343]
    }
    #[derive(Debug, Error)]
    pub enum TextDeErrorDeps<T: GraphTxnT> {
    #[error(transparent)]
    TextDe(#[from] TextDeError),
    #[error(transparent)]
    MakeChange(#[from]MakeChangeError<T>),
  • replacement in libpijul/src/change/text_changes.rs at line 200
    [3.43075][3.43075:43112]()
    ) -> Result<Self, TextDeError> {
    [3.43075]
    [3.59017]
    ) -> Result<Self, TextDeErrorDeps<T>> {
  • replacement in libpijul/src/change/text_changes.rs at line 203
    [3.122944][3.105569:105656]()
    dependencies(txn, &channel.read(), change.hashed.changes.iter()).unwrap();
    [3.122944]
    [3.43278]
    dependencies(txn, &channel.read(), change.hashed.changes.iter())?;
  • edit in libpijul/src/apply.rs at line 17
    [2.36928]
    [2.36928]
    MakeChange(crate::change::MakeChangeError<T>),
  • edit in libpijul/src/apply.rs at line 25
    [2.37258]
    [2.37258]
    ApplyError::MakeChange(e) => std::fmt::Debug::fmt(e, fmt),
  • edit in libpijul/src/apply.rs at line 35
    [2.37610]
    [2.37610]
    ApplyError::MakeChange(e) => std::fmt::Display::fmt(e, fmt),
  • edit in libpijul/src/apply.rs at line 94
    [3.123882]
    [2.39642]
    impl<C: std::error::Error, T: GraphTxnT + TreeTxnT> From<crate::change::MakeChangeError<T>>
    for ApplyError<C, T>
    {
    fn from(err: crate::change::MakeChangeError<T>) -> Self {
    ApplyError::MakeChange(err)
    }
    }