Fix ensuring unreachable code returns an error instead of panicking (#4665)
This commit is contained in:
parent
185cb9e568
commit
4145f70463
3 changed files with 19 additions and 4 deletions
core/src
|
@ -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>),
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue