You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-20 12:02:22 +03:00
handlers: remove most usage of anyhow
This commit is contained in:
@@ -37,9 +37,6 @@ pub(crate) enum RouteError {
|
||||
|
||||
#[error(transparent)]
|
||||
Internal(Box<dyn std::error::Error>),
|
||||
|
||||
#[error(transparent)]
|
||||
Anyhow(#[from] anyhow::Error),
|
||||
}
|
||||
|
||||
impl_from_error_for_route!(sqlx::Error);
|
||||
@@ -53,9 +50,6 @@ impl IntoResponse for RouteError {
|
||||
match self {
|
||||
Self::ProviderNotFound => (StatusCode::NOT_FOUND, "Provider not found").into_response(),
|
||||
Self::Internal(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
|
||||
Self::Anyhow(e) => {
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}")).into_response()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +62,7 @@ pub(crate) async fn get(
|
||||
Path(provider_id): Path<Ulid>,
|
||||
Query(query): Query<OptionalPostAuthAction>,
|
||||
) -> Result<impl IntoResponse, RouteError> {
|
||||
let (clock, mut rng) = crate::rng_and_clock()?;
|
||||
let (clock, mut rng) = crate::clock_and_rng();
|
||||
|
||||
let mut txn = pool.begin().await?;
|
||||
|
||||
|
||||
@@ -90,9 +90,6 @@ pub(crate) enum RouteError {
|
||||
|
||||
#[error(transparent)]
|
||||
Internal(Box<dyn std::error::Error>),
|
||||
|
||||
#[error(transparent)]
|
||||
Anyhow(#[from] anyhow::Error),
|
||||
}
|
||||
|
||||
impl_from_error_for_route!(mas_storage::DatabaseError);
|
||||
@@ -109,9 +106,6 @@ impl IntoResponse for RouteError {
|
||||
match self {
|
||||
Self::SessionNotFound => (StatusCode::NOT_FOUND, "Session not found").into_response(),
|
||||
Self::Internal(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
|
||||
Self::Anyhow(e) => {
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}")).into_response()
|
||||
}
|
||||
e => (StatusCode::BAD_REQUEST, e.to_string()).into_response(),
|
||||
}
|
||||
}
|
||||
@@ -128,7 +122,7 @@ pub(crate) async fn get(
|
||||
Path(provider_id): Path<Ulid>,
|
||||
Query(params): Query<QueryParams>,
|
||||
) -> Result<impl IntoResponse, RouteError> {
|
||||
let (clock, mut rng) = crate::rng_and_clock()?;
|
||||
let (clock, mut rng) = crate::clock_and_rng();
|
||||
|
||||
let mut txn = pool.begin().await?;
|
||||
|
||||
|
||||
@@ -67,9 +67,6 @@ pub(crate) enum RouteError {
|
||||
|
||||
#[error(transparent)]
|
||||
Internal(Box<dyn std::error::Error>),
|
||||
|
||||
#[error(transparent)]
|
||||
Anyhow(#[from] anyhow::Error),
|
||||
}
|
||||
|
||||
impl_from_error_for_route!(sqlx::Error);
|
||||
@@ -84,9 +81,6 @@ impl IntoResponse for RouteError {
|
||||
match self {
|
||||
Self::LinkNotFound => (StatusCode::NOT_FOUND, "Link not found").into_response(),
|
||||
Self::Internal(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
|
||||
Self::Anyhow(e) => {
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}")).into_response()
|
||||
}
|
||||
e => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
|
||||
}
|
||||
}
|
||||
@@ -107,7 +101,7 @@ pub(crate) async fn get(
|
||||
Path(link_id): Path<Ulid>,
|
||||
) -> Result<impl IntoResponse, RouteError> {
|
||||
let mut txn = pool.begin().await?;
|
||||
let (clock, mut rng) = crate::rng_and_clock()?;
|
||||
let (clock, mut rng) = crate::clock_and_rng();
|
||||
|
||||
let sessions_cookie = UpstreamSessionsCookie::load(&cookie_jar);
|
||||
let (session_id, _post_auth_action) = sessions_cookie
|
||||
@@ -204,7 +198,7 @@ pub(crate) async fn post(
|
||||
Form(form): Form<ProtectedForm<FormData>>,
|
||||
) -> Result<impl IntoResponse, RouteError> {
|
||||
let mut txn = pool.begin().await?;
|
||||
let (clock, mut rng) = crate::rng_and_clock()?;
|
||||
let (clock, mut rng) = crate::clock_and_rng();
|
||||
let form = cookie_jar.verify_form(clock.now(), form)?;
|
||||
|
||||
let sessions_cookie = UpstreamSessionsCookie::load(&cookie_jar);
|
||||
|
||||
Reference in New Issue
Block a user