aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src-tauri/src/main.rs
diff options
context:
space:
mode:
authorBegonia, HE <163421589+BegoniaHe@users.noreply.github.com>2026-01-27 03:56:21 +0100
committerBegonia, HE <163421589+BegoniaHe@users.noreply.github.com>2026-01-29 03:02:44 +0100
commitf4078c987a3899d4031acb49d72aa418432e046d (patch)
tree7f0c28c1e37428faa8726bab6cc4b843813fc420 /src-tauri/src/main.rs
parent6bb967f05b2dd32dc1cd1b849a6089bc80667aec (diff)
downloadDropOut-f4078c987a3899d4031acb49d72aa418432e046d.tar.gz
DropOut-f4078c987a3899d4031acb49d72aa418432e046d.zip
feat(java): Enhance Java detection and error handling
- Added support for detecting Java installations from SDKMAN! in `find_sdkman_java`. - Improved `run_which_command_with_timeout` to handle command timeouts gracefully. - Introduced a unified `JavaError` enum for consistent error handling across Java operations. - Updated functions to return `Result` types instead of `Option` for better error reporting. - Enhanced `load_cached_catalog` and `save_catalog_cache` to use `JavaError`. - Refactored `fetch_java_catalog`, `fetch_java_release`, and `fetch_available_versions` to return `JavaError`. - Improved validation functions to return detailed errors when checking Java installations. - Added tests for version parsing and compatibility checks. - Updated `resolve_java_for_launch` to handle instance-specific and global Java paths.
Diffstat (limited to 'src-tauri/src/main.rs')
-rw-r--r--src-tauri/src/main.rs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index e0a71b5..b74c746 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -1549,7 +1549,9 @@ async fn fetch_adoptium_java(
"jdk" => core::java::ImageType::Jdk,
_ => core::java::ImageType::Jre,
};
- core::java::fetch_java_release(major_version, img_type).await
+ core::java::fetch_java_release(major_version, img_type)
+ .await
+ .map_err(|e| e.to_string())
}
/// Download and install Adoptium Java
@@ -1565,13 +1567,17 @@ async fn download_adoptium_java(
_ => core::java::ImageType::Jre,
};
let path = custom_path.map(std::path::PathBuf::from);
- core::java::download_and_install_java(&app_handle, major_version, img_type, path).await
+ core::java::download_and_install_java(&app_handle, major_version, img_type, path)
+ .await
+ .map_err(|e| e.to_string())
}
/// Get available Adoptium Java versions
#[tauri::command]
async fn fetch_available_java_versions() -> Result<Vec<u32>, String> {
- core::java::fetch_available_versions().await
+ core::java::fetch_available_versions()
+ .await
+ .map_err(|e| e.to_string())
}
/// Fetch Java catalog with platform availability (uses cache)
@@ -1579,7 +1585,9 @@ async fn fetch_available_java_versions() -> Result<Vec<u32>, String> {
async fn fetch_java_catalog(
app_handle: tauri::AppHandle,
) -> Result<core::java::JavaCatalog, String> {
- core::java::fetch_java_catalog(&app_handle, false).await
+ core::java::fetch_java_catalog(&app_handle, false)
+ .await
+ .map_err(|e| e.to_string())
}
/// Refresh Java catalog (bypass cache)
@@ -1587,7 +1595,9 @@ async fn fetch_java_catalog(
async fn refresh_java_catalog(
app_handle: tauri::AppHandle,
) -> Result<core::java::JavaCatalog, String> {
- core::java::fetch_java_catalog(&app_handle, true).await
+ core::java::fetch_java_catalog(&app_handle, true)
+ .await
+ .map_err(|e| e.to_string())
}
/// Cancel current Java download