From 2e36c28c0d3d33fa76eab1a63275d5f11d9e630c Mon Sep 17 00:00:00 2001 From: spinline Date: Sun, 8 Feb 2026 05:41:07 +0300 Subject: [PATCH] fix(frontend): replace unwrap() with expect() for better error messages - console_log::init_with_level() now uses expect() - web_sys::window() now uses expect() with helpful message - window.document() now uses expect() - document.body() now uses expect() This provides meaningful error messages if WASM initialization fails. --- frontend/src/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib.rs b/frontend/src/lib.rs index 90f7a86..9ea112d 100644 --- a/frontend/src/lib.rs +++ b/frontend/src/lib.rs @@ -11,11 +11,15 @@ use app::App; #[wasm_bindgen(start)] pub fn main() { console_error_panic_hook::set_once(); - console_log::init_with_level(log::Level::Debug).unwrap(); + console_log::init_with_level(log::Level::Debug) + .expect("Failed to initialize logging"); - let window = web_sys::window().unwrap(); - let document = window.document().unwrap(); - let body = document.body().unwrap(); + let window = web_sys::window() + .expect("Failed to access window - browser may not be fully loaded"); + let document = window.document() + .expect("Failed to access document"); + let body = document.body() + .expect("Failed to access document body"); // Add app-loaded class to body to hide spinner via CSS let _ = body.class_list().add_1("app-loaded");