diff --git a/db-traits/errors.rs b/db-traits/errors.rs index b03f3d2c..58b39aa8 100644 --- a/db-traits/errors.rs +++ b/db-traits/errors.rs @@ -214,11 +214,13 @@ pub enum DbErrorKind { UnrecognizedIdent(String), /// An entid->ident mapping failed. - /// We also use this error if you try to transact an entid that we didn't allocate, - /// in part because we blow the stack in error_chain if we define a new enum! - #[fail(display = "unrecognized or no ident found for entid: {}", _0)] + #[fail(display = "no ident found for entid: {}", _0)] UnrecognizedEntid(Entid), + /// Tried to transact an entid that isn't allocated. + #[fail(display = "entid not allocated: {}", _0)] + UnallocatedEntid(Entid), + #[fail(display = "unknown attribute for entid: {}", _0)] UnknownAttribute(Entid), diff --git a/db/src/tx.rs b/db/src/tx.rs index 1a5f91eb..7669622d 100644 --- a/db/src/tx.rs +++ b/db/src/tx.rs @@ -294,7 +294,7 @@ impl<'conn, 'a, W> Tx<'conn, 'a, W> where W: TransactWatcher { if self.partition_map.contains_entid(e) { Ok(KnownEntid(e)) } else { - bail!(DbErrorKind::UnrecognizedEntid(e)) + bail!(DbErrorKind::UnallocatedEntid(e)) } } diff --git a/src/conn.rs b/src/conn.rs index dde86076..921da9a5 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -895,7 +895,7 @@ mod tests { match conn.transact(&mut sqlite, t.as_str()) { Err(MentatError::DbError(e)) => { - assert_eq!(e.kind(), ::db_traits::errors::DbErrorKind::UnrecognizedEntid(next + 1)); + assert_eq!(e.kind(), ::db_traits::errors::DbErrorKind::UnallocatedEntid(next + 1)); }, x => panic!("expected db error, got {:?}", x), } @@ -923,7 +923,7 @@ mod tests { match conn.transact(&mut sqlite, t.as_str()) { Err(MentatError::DbError(e)) => { // All this, despite this being the ID we were about to allocate! - assert_eq!(e.kind(), ::db_traits::errors::DbErrorKind::UnrecognizedEntid(next)); + assert_eq!(e.kind(), ::db_traits::errors::DbErrorKind::UnallocatedEntid(next)); }, x => panic!("expected db error, got {:?}", x), }