diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-29 12:50:39 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-29 12:50:39 -0800 |
commit | 5aac6ec1a46a64b810f4695de968a10cab000914 (patch) | |
tree | c3086929fbd27c596dd95c5c8434eabc9d6363c8 /rust/src/endpoints.rs | |
parent | 6f8410f4f77a7724081e5573f904bebb3b68b7c1 (diff) | |
download | fatcat-5aac6ec1a46a64b810f4695de968a10cab000914.tar.gz fatcat-5aac6ec1a46a64b810f4695de968a10cab000914.zip |
better database NotFound error propagation
Diffstat (limited to 'rust/src/endpoints.rs')
-rw-r--r-- | rust/src/endpoints.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/rust/src/endpoints.rs b/rust/src/endpoints.rs index 2e467957..4271848a 100644 --- a/rust/src/endpoints.rs +++ b/rust/src/endpoints.rs @@ -34,7 +34,7 @@ macro_rules! generic_auth_err_responses { ($val:ident, $resp_type:ident) => { //use crate::errors::FatcatError::*; match $val { - NotFound(_, _) => $resp_type::NotFound($val.into()), + NotFound(_, _) | DatabaseRowNotFound => $resp_type::NotFound($val.into()), InvalidCredentials(_) | InsufficientPrivileges(_) => $resp_type::Forbidden($val.into()), DatabaseError(_) | InternalError(_) => { error!("{}", $val); @@ -50,7 +50,7 @@ macro_rules! generic_err_responses { ($val:ident, $resp_type:ident) => { //use crate::errors::FatcatError::*; match $val { - NotFound(_, _) => $resp_type::NotFound($val.into()), + NotFound(_, _) | DatabaseRowNotFound => $resp_type::NotFound($val.into()), DatabaseError(_) | InternalError(_) => { error!("{}", $val); capture_fail(&$val); @@ -967,7 +967,9 @@ impl Api for Server { CreateEditgroupResponse::SuccessfullyCreated(eg) } Err(fe) => match fe { - NotFound(_, _) => CreateEditgroupResponse::NotFound(fe.into()), + NotFound(_, _) | DatabaseRowNotFound => { + CreateEditgroupResponse::NotFound(fe.into()) + } DatabaseError(_) | InternalError(_) => { error!("{}", fe); capture_fail(&fe); @@ -1137,6 +1139,9 @@ impl Api for Server { AuthOidcResponse::Found(result) } Err(fe) => match fe { + InvalidCredentials(_) | InsufficientPrivileges(_) => { + AuthOidcResponse::Forbidden(fe.into()) + } DatabaseError(_) | InternalError(_) => { error!("{}", fe); capture_fail(&fe); @@ -1182,6 +1187,9 @@ impl Api for Server { message: "auth check successful!".to_string(), }), Err(fe) => match fe { + InvalidCredentials(_) | InsufficientPrivileges(_) => { + AuthCheckResponse::Forbidden(fe.into()) + } DatabaseError(_) | InternalError(_) => { error!("{}", fe); capture_fail(&fe); |