From 3a9f44a39573ef2eb362f002b176652985aa7966 Mon Sep 17 00:00:00 2001 From: arctic_hen7 Date: Tue, 21 Sep 2021 14:12:57 +1000 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20handled=20page=20renderin?= =?UTF-8?q?g=20errors=20properly=20at=20initial=20load?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now returns nuanced error rather than blank 500, as subsequent loads do. --- packages/perseus-actix-web/src/initial_load.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/perseus-actix-web/src/initial_load.rs b/packages/perseus-actix-web/src/initial_load.rs index 5d05e3fed3..94e81d1d7b 100644 --- a/packages/perseus-actix-web/src/initial_load.rs +++ b/packages/perseus-actix-web/src/initial_load.rs @@ -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, }; @@ -127,8 +128,12 @@ pub async fn initial_load( .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() + ); } };