Log not found URI.
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
use axum::http::Uri;
|
||||||
|
|
||||||
use crate::{domain::DomainError, repository::RepositoryError, routes::extractors::ExtractorError};
|
use crate::{domain::DomainError, repository::RepositoryError, routes::extractors::ExtractorError};
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
@@ -29,6 +31,9 @@ pub enum AppError {
|
|||||||
#[error("not found")]
|
#[error("not found")]
|
||||||
NotFound,
|
NotFound,
|
||||||
|
|
||||||
|
#[error("not found: {0}")]
|
||||||
|
NotFoundWithUri(Uri),
|
||||||
|
|
||||||
#[error("race condition occurred")]
|
#[error("race condition occurred")]
|
||||||
RaceCondition,
|
RaceCondition,
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,6 @@ pub fn create_router(state: AppState) -> axum::Router {
|
|||||||
axum::Router::new()
|
axum::Router::new()
|
||||||
.nest("/api", api)
|
.nest("/api", api)
|
||||||
.route("/health", get(async || StatusCode::NO_CONTENT))
|
.route("/health", get(async || StatusCode::NO_CONTENT))
|
||||||
.fallback(async || AppError::NotFound)
|
.fallback(async |uri: axum::http::Uri| AppError::NotFoundWithUri(uri))
|
||||||
.with_state(state)
|
.with_state(state)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ impl ClientError for AppError {
|
|||||||
Self::InvalidRefreshToken => (StatusCode::UNAUTHORIZED, "Invalid refresh token".into()),
|
Self::InvalidRefreshToken => (StatusCode::UNAUTHORIZED, "Invalid refresh token".into()),
|
||||||
Self::RaceCondition => (StatusCode::CONFLICT, "Try again".into()),
|
Self::RaceCondition => (StatusCode::CONFLICT, "Try again".into()),
|
||||||
Self::NotFound => (StatusCode::NOT_FOUND, "Not found".into()),
|
Self::NotFound => (StatusCode::NOT_FOUND, "Not found".into()),
|
||||||
|
Self::NotFoundWithUri(_) => (StatusCode::NOT_FOUND, "Not found".into()),
|
||||||
Self::Domain(error) => error.client_response(),
|
Self::Domain(error) => error.client_response(),
|
||||||
Self::Extractor(error) => error.client_response(),
|
Self::Extractor(error) => error.client_response(),
|
||||||
Self::Repository(error) => error.client_response(),
|
Self::Repository(error) => error.client_response(),
|
||||||
|
|||||||
Reference in New Issue
Block a user