mirror of
				https://github.com/Tim-Paik/neutauri.git
				synced 2024-10-12 23:29:41 +00:00 
			
		
		
		
	try using anyhow
This commit is contained in:
		| @ -4,6 +4,7 @@ name = "neutauri_bundler" | ||||
| version = "0.1.0" | ||||
|  | ||||
| [dependencies] | ||||
| anyhow = "1.0" | ||||
| bincode = "1.3" | ||||
| brotli = "3.3" | ||||
| gumdrop = "0.8" | ||||
|  | ||||
| @ -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<Vec<u8>> { | ||||
| fn get_runtime_data() -> anyhow::Result<Vec<u8>> { | ||||
|     Ok(include_bytes!("../../target/release/neutauri_runtime").to_vec()) | ||||
| } | ||||
|  | ||||
| #[cfg(windows)] | ||||
| fn get_runtime_data() -> io::Result<Vec<u8>> { | ||||
| fn get_runtime_data() -> anyhow::Result<Vec<u8>> { | ||||
|     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<Vec<u8>> { | ||||
|     )?; | ||||
|     // 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))?; | ||||
|  | ||||
| @ -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::<Vec<_>>(); | ||||
|     let args = Args::parse_args(&args[1..], gumdrop::ParsingStyle::default()).unwrap_or_else(|e| { | ||||
|         eprintln!("{}: {}", args[0], e); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user