aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/entity_crud.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-10 00:16:54 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-10 00:16:54 -0800
commit39477ac76cc67d5b2c01081e0730a781bf5fe572 (patch)
tree1f47ef730292e7fe0d40cb4f2a6c988dd3782c6d /rust/src/entity_crud.rs
parent67c3460d251a4e559a1126b5fe66fe996f840010 (diff)
downloadfatcat-39477ac76cc67d5b2c01081e0730a781bf5fe572.tar.gz
fatcat-39477ac76cc67d5b2c01081e0730a781bf5fe572.zip
cleanups; NotFound errors
Diffstat (limited to 'rust/src/entity_crud.rs')
-rw-r--r--rust/src/entity_crud.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/rust/src/entity_crud.rs b/rust/src/entity_crud.rs
index 43ed2083..0c1e29b0 100644
--- a/rust/src/entity_crud.rs
+++ b/rust/src/entity_crud.rs
@@ -273,7 +273,12 @@ macro_rules! generic_db_get {
},
None => {
// return a stub (deleted) entity if it's just deleted state
- let ident_row: Self::IdentRow = $ident_table::table.find(ident.to_uuid()).first(conn)?;
+ let ident_row: Self::IdentRow = match $ident_table::table.find(ident.to_uuid()).first(conn) {
+ Ok(row) => row,
+ Err(diesel::result::Error::NotFound) =>
+ Err(FatcatError::NotFound(stringify!($ident_table).to_string(), ident.to_string()))?,
+ Err(e) => Err(e)?,
+ };
if ident_row.rev_id.is_none() {
Self::from_deleted_row(ident_row)
} else {
@@ -288,7 +293,12 @@ macro_rules! generic_db_get {
macro_rules! generic_db_get_rev {
($rev_table:ident) => {
fn db_get_rev(conn: &DbConn, rev_id: Uuid, hide: HideFlags) -> Result<Self> {
- let rev = $rev_table::table.find(rev_id).first(conn)?;
+ let rev = match $rev_table::table.find(rev_id).first(conn) {
+ Ok(rev) => rev,
+ Err(diesel::result::Error::NotFound) =>
+ Err(FatcatError::NotFound(stringify!($rev_table).to_string(), rev_id.to_string()))?,
+ Err(e) => Err(e)?,
+ };
Self::db_from_row(conn, rev, None, hide)
}