Skip to content

Commit

Permalink
Refine error handling harder
Browse files Browse the repository at this point in the history
  • Loading branch information
plotnick committed Jul 7, 2022
1 parent bf53d38 commit 8ce7e42
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions nexus/src/db/datastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4326,7 +4326,7 @@ impl DataStore {
#[derive(Debug)]
enum TokenGrantError {
RequestNotFound,
ConcurrentRequests,
TooManyRequests,
}
type TxnError = TransactionError<TokenGrantError>;

Expand All @@ -4338,7 +4338,7 @@ impl DataStore {
}
1 => Ok(insert_token.get_result(conn)?),
_ => Err(TxnError::CustomError(
TokenGrantError::ConcurrentRequests,
TokenGrantError::TooManyRequests,
)),
})
.await
Expand All @@ -4351,10 +4351,8 @@ impl DataStore {
),
}
}
TxnError::CustomError(TokenGrantError::ConcurrentRequests) => {
Error::invalid_request(
"token grant failed due to concurrent requests",
)
TxnError::CustomError(TokenGrantError::TooManyRequests) => {
Error::internal_error("unexpectedly found multiple device auth requests for the same user code")
}
TxnError::Pool(e) => {
public_error_from_diesel_pool(e, ErrorHandler::Server)
Expand Down

0 comments on commit 8ce7e42

Please sign in to comment.