fix(error): migrate misc.rs to AppError

This commit is contained in:
Hibryda 2026-03-18 01:22:27 +01:00
parent 07f41fe0ea
commit 1978475766

View file

@ -1,5 +1,7 @@
// Miscellaneous commands — CLI args, URL opening, frontend telemetry
use crate::error::AppError;
#[tauri::command]
pub fn cli_get_group() -> Option<String> {
let args: Vec<String> = std::env::args().collect();
@ -18,14 +20,14 @@ pub fn cli_get_group() -> Option<String> {
}
#[tauri::command]
pub fn open_url(url: String) -> Result<(), String> {
pub fn open_url(url: String) -> Result<(), AppError> {
if !url.starts_with("http://") && !url.starts_with("https://") {
return Err("Only http/https URLs are allowed".into());
return Err(AppError::validation("Only http/https URLs are allowed"));
}
std::process::Command::new("xdg-open")
.arg(&url)
.spawn()
.map_err(|e| format!("Failed to open URL: {e}"))?;
.map_err(|e| AppError::internal(format!("Failed to open URL: {e}")))?;
Ok(())
}