Return a 404 when paring the route fails (#3860)
* return a 404 when paring the route fails * add a playwright test for fullstack routing status codes * Fix new playwright test * document SSRError * Make SSRError public and fix clippy * Move the error display bound to the routable trait * fix clippy * return a more generic 404 message * fix router tests
This commit is contained in:
1 parent
7b7357037f
commit
09a4b5eb4e
18 files changed
+253
-46
No files matched your search
@@ -69,6 +69,7 @@ use http::header::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::render::SSRError;
|
||||
use crate::{prelude::*, ContextProviders};
|
||||
|
||||
/// A extension trait with utilities for integrating Dioxus with your Axum router.
|
||||
@@ -413,10 +414,17 @@ pub async fn render_handler(
|
||||
apply_request_parts_to_response(headers, &mut response);
|
||||
Result::<http::Response<axum::body::Body>, StatusCode>::Ok(response)
|
||||
}
|
||||
Err(e) => {
|
||||
Err(SSRError::Incremental(e)) => {
|
||||
tracing::error!("Failed to render page: {}", e);
|
||||
Ok(report_err(e).into_response())
|
||||
}
|
||||
Err(SSRError::Routing(e)) => {
|
||||
tracing::trace!("Page not found: {}", e);
|
||||
Ok(Response::builder()
|
||||
.status(StatusCode::NOT_FOUND)
|
||||
.body(Body::from("Page not found"))
|
||||
.unwrap())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user