Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
slightly improved http error status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
chunningham committed Jul 26, 2023
1 parent 03bad6a commit 4f1e5fa
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub async fn delegate(
(
match e {
TxError::OrbitNotFound => Status::NotFound,
TxError::DbErr(DbErr::ConnectionAcquire) => Status::ServiceUnavailable,
_ => Status::Unauthorized,
},
e.to_string(),
Expand Down Expand Up @@ -183,7 +184,16 @@ pub async fn invoke(
_ => unreachable!(),
},
)
.map_err(|e| (Status::Unauthorized, e.to_string()));
.map_err(|e| {
(
match e {
TxError::OrbitNotFound => Status::NotFound,
TxError::DbErr(DbErr::ConnectionAcquire) => Status::ServiceUnavailable,
_ => Status::Unauthorized,
},
e.to_string(),
)
});

timer.observe_duration();
res
Expand Down

0 comments on commit 4f1e5fa

Please sign in to comment.