chore: minor changes to scene and app error logging

This commit is contained in:
alphafetus committed 2026-08-27 11:24:10 -04:00
1 parent 8683f8b565
commit 508a69d385
2 files changed
+13 -3

No files matched your search

+4 -1
View File
@@ -573,7 +573,10 @@ impl App {
..Default::default() ..Default::default()
}, },
) )
.map_err(|e| format!("Failed to create instance: {e}")) .map_err(|e| {
let err = e.unwrap();
format!("Failed to create instance: {err}")
})
} }
} }
+9 -2
View File
@@ -1,5 +1,6 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap; use std::collections::HashMap;
use std::env;
use std::io::Read; use std::io::Read;
use std::path::Path; use std::path::Path;
@@ -45,16 +46,22 @@ impl Scene {
let scene: Self = let scene: Self =
postcard::from_bytes(contents.as_slice()).expect("Couldn't deserialize scene"); postcard::from_bytes(contents.as_slice()).expect("Couldn't deserialize scene");
Self::resolve_paths(path, scene) env::set_current_dir(path.parent().unwrap())
.expect("couldn't set current working directory");
scene
} }
pub fn from_file_json<P: AsRef<Path>>(path: P) -> Self { pub fn from_file_json<P: AsRef<Path>>(path: P) -> Self {
let path = path.as_ref(); let path = path.as_ref();
let file = std::fs::File::open(path).unwrap(); let file = std::fs::File::open(path).unwrap();
env::set_current_dir(path.parent().unwrap())
.expect("couldn't set current working directory");
let scene: Self = serde_json::from_reader(file).unwrap(); let scene: Self = serde_json::from_reader(file).unwrap();
Self::resolve_paths(path, scene) scene
} }
fn resolve_paths(scene_path: &Path, mut scene: Self) -> Self { fn resolve_paths(scene_path: &Path, mut scene: Self) -> Self {