diff --git a/Cargo.lock b/Cargo.lock index e73d4c1..5e8ad57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1171,6 +1171,7 @@ checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121" name = "neutauri_bundler" version = "0.1.0" dependencies = [ + "anyhow", "bincode", "brotli", "gumdrop", diff --git a/neutauri_bundler/Cargo.toml b/neutauri_bundler/Cargo.toml index 5149660..824ce2c 100644 --- a/neutauri_bundler/Cargo.toml +++ b/neutauri_bundler/Cargo.toml @@ -4,6 +4,7 @@ name = "neutauri_bundler" version = "0.1.0" [dependencies] +anyhow = "1.0" bincode = "1.3" brotli = "3.3" gumdrop = "0.8" diff --git a/neutauri_bundler/src/bundle.rs b/neutauri_bundler/src/bundle.rs index ce86808..a22d731 100644 --- a/neutauri_bundler/src/bundle.rs +++ b/neutauri_bundler/src/bundle.rs @@ -1,4 +1,5 @@ use crate::data; +use anyhow::Context; use std::{ env, fs, hash::{Hash, Hasher}, @@ -18,12 +19,12 @@ fn options() -> fs::OpenOptions { } #[cfg(not(windows))] -fn get_runtime_data() -> io::Result> { +fn get_runtime_data() -> anyhow::Result> { Ok(include_bytes!("../../target/release/neutauri_runtime").to_vec()) } #[cfg(windows)] -fn get_runtime_data() -> io::Result> { +fn get_runtime_data() -> anyhow::Result> { let mut hasher = std::collections::hash_map::DefaultHasher::new(); hasher.write(b"neutauri_runtime"); std::time::SystemTime::now().hash(&mut hasher); @@ -35,10 +36,11 @@ fn get_runtime_data() -> io::Result> { )?; // let mut updater = rcedit::ResourceUpdater::new(); // updater.load(&temp_path).unwrap(); // TODO: handle error - fs::read(&temp_path) + + fs::read(&temp_path).with_context(|| format!("Failed to read {}", temp_path.display())) } -pub fn bundle(config_path: String) -> io::Result<()> { +pub fn bundle(config_path: String) -> anyhow::Result<()> { let config_path = std::path::Path::new(&config_path).canonicalize()?; let config: data::Config = toml::from_str(fs::read_to_string(&config_path)?.as_str()) .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; diff --git a/neutauri_bundler/src/main.rs b/neutauri_bundler/src/main.rs index f0153e6..e55abe1 100644 --- a/neutauri_bundler/src/main.rs +++ b/neutauri_bundler/src/main.rs @@ -59,7 +59,7 @@ fn print_help_and_exit(args: Args) { std::process::exit(0); } -fn main() -> wry::Result<()> { +fn main() -> anyhow::Result<()> { let args = std::env::args().collect::>(); let args = Args::parse_args(&args[1..], gumdrop::ParsingStyle::default()).unwrap_or_else(|e| { eprintln!("{}: {}", args[0], e);