@@ -20,16 +20,15 @@ use wasm_bindgen::prelude::*;
20/// Since this is marked `#[wasm_bindgen(start)]` it is automatically invoked
20/// Since this is marked `#[wasm_bindgen(start)]` it is automatically invoked
21/// once the wasm module instantiated on the Web page.
21/// once the wasm module instantiated on the Web page.
22#[wasm_bindgen(start)]
22#[wasm_bindgen(start)]
23−pub fn run() {
23+pub fn run() -> Result<(), JsValue> {
24 // Set up the logging for debugging if/when things go wrong.
24 // Set up the logging for debugging if/when things go wrong.
25 init_logging();
25 init_logging();
27 // Grab the TODO app container.
27 // Grab the TODO app container.
28 let document = utils::document();
28 let document = utils::document();
29 let container = document
29 let container = document
30− .query_selector(".todoapp")
30+ .query_selector(".todoapp")?
31− .unwrap_throw()
31+ .ok_or_else(|| js_sys::Error::new("could not find `.todoapp` container"))?;
34 // Create a new `Todos` render component.
33 // Create a new `Todos` render component.
35 let todos = Todos::<Controller>::new();
34 let todos = Todos::<Controller>::new();
@@ -42,14 +41,16 @@ pub fn run() {
43 // Run the virtual DOM forever and don't unmount it.
42 // Run the virtual DOM forever and don't unmount it.
44 vdom.forget();
43 vdom.forget();
47cfg_if::cfg_if! {
48cfg_if::cfg_if! {
48 if #[cfg(feature = "logging")] {
49 if #[cfg(feature = "logging")] {
49 fn init_logging() {
50 fn init_logging() {
51 console_error_panic_hook::set_once();
51 console_error_panic_hook::set_once();
52+ console_log::init_with_level(log::Level::Trace)
52− console_log::init_with_level(Level::Trace).expect_throw("should initialize logging OK");
53+ .expect_throw("should initialize logging OK");
55 fn init_logging() {
56 fn init_logging() {