diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index ceea520..2fc22a5 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -298,32 +298,22 @@ pub async fn install_paths( let file = Path::new(&path) .file_name() .and_then(|name| name.to_str()) - .unwrap_or_default(); - - if file.is_empty() { - println!("Error: Unable to obtain file"); - continue; - } + .ok_or_else(|| String::from("File name not found"))?; let version_dir = LAUNCHER_DIR.data_dir().join(&state.lock().unwrap().version); let mc_child = if path.ends_with(".jar") { - Some("mods") + "mods" } else { - None + return Err(String::from("Invalid file type")); }; - if let Some(mc_child) = mc_child { - match fs::copy(path, version_dir.join(mc_child).join(file)).await { - Ok(_) => { - app.emit("path-installed", path.to_string()) - .map_err(|e| e.to_string())?; - } - Err(e) => { - println!("Error: failed to copy mod {file:?}: {e}") - } - } - } + fs::copy(path, version_dir.join(mc_child).join(file)) + .await + .map_err(|e| e.to_string())?; + + app.emit("path-installed", path.to_string()) + .map_err(|e| e.to_string())?; } Ok(()) diff --git a/src/App.tsx b/src/App.tsx index 15e90ef..daa7827 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -82,7 +82,7 @@ export default function App() { toast.promise(installPaths(version, [path]), { loading: `${fileName}`, success: `${fileName}`, - error: `${fileName} Failed` + error: (e) => `${fileName} Failed: ${e}` }).catch(console.error); }); });