Fix ensuring unreachable code returns an error instead of panicking ()

This commit is contained in:
Tobie Morgan Hitchcock 2024-09-02 11:02:53 +01:00 committed by GitHub
parent 185cb9e568
commit 4145f70463
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 4 deletions

View file

@ -35,18 +35,21 @@ pub(crate) enum Iterable {
Index(Table, IteratorRef),
}
#[derive(Debug)]
pub(crate) struct Processed {
pub(crate) rid: Option<Arc<Thing>>,
pub(crate) ir: Option<Arc<IteratorRecord>>,
pub(crate) val: Operable,
}
#[derive(Debug)]
pub(crate) enum Operable {
Value(Arc<Value>),
Mergeable(Arc<Value>, Arc<Value>),
Relatable(Thing, Arc<Value>, Thing, Option<Arc<Value>>),
}
#[derive(Debug)]
pub(crate) enum Workable {
Normal,
Insert(Arc<Value>),

View file

@ -80,9 +80,16 @@ impl Document {
// Send back the result
let _ = chn.send(res).await;
// Break the loop
break;
return Ok(());
}
// Everything went ok
// We shouldn't really reach this part, but if we
// did it was probably due to the fact that we
// encountered two Err::RetryWithId errors due to
// two separtate UNIQUE index definitions, and it
// wasn't possible to detect which record was the
// correct one to be updated
let _ = chn.send(Err(Error::Unreachable("Internal error"))).await;
// Break the loop
Ok(())
}
}

View file

@ -74,7 +74,12 @@ impl Document {
// Send back the result
return res;
}
// We should never get here
unreachable!()
// We shouldn't really reach this part, but if we
// did it was probably due to the fact that we
// encountered two Err::RetryWithId errors due to
// two separtate UNIQUE index definitions, and it
// wasn't possible to detect which record was the
// correct one to be updated
Err(Error::Unreachable("Internal error"))
}
}