1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-20 12:02:22 +03:00

Simplify error handling in user-facing routes

This commit is contained in:
Quentin Gliech
2022-05-10 16:51:12 +02:00
parent 2cba5e7ad2
commit ca7b26cf18
17 changed files with 192 additions and 383 deletions

View File

@@ -13,19 +13,18 @@
// limitations under the License.
use axum::{extract::Extension, response::IntoResponse};
use mas_axum_utils::{internal_error, FancyError};
use mas_axum_utils::FancyError;
use sqlx::PgPool;
use tracing::{info_span, Instrument};
pub async fn get(Extension(pool): Extension<PgPool>) -> Result<impl IntoResponse, FancyError> {
let mut conn = pool.acquire().await.map_err(internal_error)?;
let mut conn = pool.acquire().await?;
sqlx::query("SELECT $1")
.bind(1_i64)
.execute(&mut conn)
.instrument(info_span!("DB health"))
.await
.map_err(internal_error)?;
.await?;
Ok("ok")
}