Skip to content

Commit

Permalink
fix: 🐛 handled page rendering errors properly at initial load
Browse files Browse the repository at this point in the history
Now returns nuanced error rather than blank 500, as subsequent loads do.
  • Loading branch information
arctic-hen7 committed Sep 21, 2021
1 parent cb60be0 commit 3a9f44a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/perseus-actix-web/src/initial_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use actix_web::{http::StatusCode, web, HttpRequest, HttpResponse};
use perseus::error_pages::ErrorPageData;
use perseus::router::{match_route, RouteInfo, RouteVerdict};
use perseus::{
err_to_status_code,
serve::get_page_for_template_and_translator, ConfigManager, ErrorPages, SsrNode,
TranslationsManager, Translator,
};
Expand Down Expand Up @@ -127,8 +128,12 @@ pub async fn initial_load<C: ConfigManager, T: TranslationsManager>(
.await;
let page_data = match page_data {
Ok(page_data) => page_data,
// We parse the error to return an appropriate status code
Err(err) => {
return html_err(500, &err.to_string());
return html_err(
err_to_status_code(&err),
&err.to_string()
);
}
};

Expand Down

0 comments on commit 3a9f44a

Please sign in to comment.