@@ -20,16 +20,15 @@ use wasm_bindgen::prelude::*;
2020/// Since this is marked `#[wasm_bindgen(start)]` it is automatically invoked
2121/// once the wasm module instantiated on the Web page.
2222#[wasm_bindgen(start)]
23−pub fn run() {
23+pub fn run() -> Result<(), JsValue> {
2424 // Set up the logging for debugging if/when things go wrong.
2525 init_logging();
2626
2727 // Grab the TODO app container.
2828 let document = utils::document();
2929 let container = document
30− .query_selector(".todoapp")
31− .unwrap_throw()
32− .unwrap_throw();
30+ .query_selector(".todoapp")?
31+ .ok_or_else(|| js_sys::Error::new("could not find `.todoapp` container"))?;
3332
3433 // Create a new `Todos` render component.
3534 let todos = Todos::<Controller>::new();
@@ -42,14 +41,16 @@ pub fn run() {
4241
4342 // Run the virtual DOM forever and don't unmount it.
4443 vdom.forget();
44+
45+ Ok(())
4546}
4647
4748cfg_if::cfg_if! {
4849 if #[cfg(feature = "logging")] {
4950 fn init_logging() {
50− use log::*;
5151 console_error_panic_hook::set_once();
52− console_log::init_with_level(Level::Trace).expect_throw("should initialize logging OK");
52+ console_log::init_with_level(log::Level::Trace)
53+ .expect_throw("should initialize logging OK");
5354 }
5455 } else {
5556 fn init_logging() {