Enable descriptive HTTP errors to be returned from DB layer

For now, we only use this when redeeming an invite code.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Nathan Sobo 2022-05-19 11:55:55 -06:00
parent d1b7a249b4
commit 3d7e912c6b
5 changed files with 45 additions and 7 deletions

View file

@ -88,6 +88,18 @@ impl From<sqlx::Error> for Error {
}
}
impl From<axum::Error> for Error {
fn from(error: axum::Error) -> Self {
Self::Internal(error.into())
}
}
impl From<hyper::Error> for Error {
fn from(error: hyper::Error) -> Self {
Self::Internal(error.into())
}
}
impl IntoResponse for Error {
fn into_response(self) -> axum::response::Response {
match self {