Don't crash on the web when loading a nonexistent file. This now happens, because we try to load prebaked results for synthetic scenarios.
@@ -199,10 +199,16 @@ mod wasm_loader {
// while. Any way to make it still be nonblockingish? Maybe put some of the work
// inside that spawn_local?
- // TODO Plumb failures
- let obj: T = abstutil::from_binary(&resp).unwrap();
+ match abstutil::from_binary(&resp) {
+ Ok(obj) => {
return (self.on_load.take().unwrap())(ctx, app, Some(obj));
}
+ Err(err) => {
+ error!("{}: {}", self.url, err);
+ return (self.on_load.take().unwrap())(ctx, app, None);
+ }
+ }
+ }
self.panel = ctx.make_loading_screen(Text::from_multiline(vec![
Line(format!("Loading {}...", self.url)),
