fix(error): migrate misc.rs to AppError
This commit is contained in:
parent
07f41fe0ea
commit
1978475766
1 changed files with 5 additions and 3 deletions
|
|
@ -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(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue