mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-30 22:32:47 -07:00
feat: display error overlay (#607)
Co-authored-by: Marco Pasqualetti <marco.pasqualetti@live.com>
This commit is contained in:
+21
-10
@@ -36,10 +36,10 @@ struct ProdJs;
|
||||
impl ProdJs {
|
||||
thread_local! {
|
||||
pub static SSR: RefCell<Ssr<'static, 'static>> = RefCell::new(
|
||||
Ssr::from(
|
||||
read_to_string(PathBuf::from(PROD_BUNDLE_PATH)).expect("Server bundle not found"), ""
|
||||
).unwrap()
|
||||
)
|
||||
Ssr::from(
|
||||
read_to_string(PathBuf::from(PROD_BUNDLE_PATH)).expect("Server bundle not found"), ""
|
||||
).unwrap()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,11 +47,22 @@ struct DevJs;
|
||||
|
||||
impl DevJs {
|
||||
pub fn render_to_string(params: Option<&str>) -> Result<String, SsrError> {
|
||||
Ssr::from(
|
||||
read_to_string(PathBuf::from(DEV_BUNDLE_PATH)).expect("Server bundle not found"),
|
||||
"",
|
||||
)
|
||||
.unwrap()
|
||||
.render_to_string(params)
|
||||
let bundle_path = read_to_string(PathBuf::from(DEV_BUNDLE_PATH));
|
||||
|
||||
if let Ok(source) = bundle_path {
|
||||
let ssr = Ssr::from(source, "");
|
||||
if let Ok(mut ssr) = ssr {
|
||||
ssr.render_to_string(params)
|
||||
} else {
|
||||
let fallback_html = read_to_string(PathBuf::from("./.tuono/index.html"))
|
||||
.unwrap_or("Fallback HTML not loaded".to_string());
|
||||
Ok(fallback_html.replace("[SERVER_PAYLOAD]", params.unwrap_or("")))
|
||||
}
|
||||
} else {
|
||||
let fallback_html = read_to_string(PathBuf::from("./.tuono/index.html"))
|
||||
.unwrap_or("Fallback HTML not loaded".to_string());
|
||||
|
||||
Ok(fallback_html.replace("[SERVER_PAYLOAD]", params.unwrap_or("")))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user