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
|
// Miscellaneous commands — CLI args, URL opening, frontend telemetry
|
||||||
|
|
||||||
|
use crate::error::AppError;
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn cli_get_group() -> Option<String> {
|
pub fn cli_get_group() -> Option<String> {
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
|
@ -18,14 +20,14 @@ pub fn cli_get_group() -> Option<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[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://") {
|
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")
|
std::process::Command::new("xdg-open")
|
||||||
.arg(&url)
|
.arg(&url)
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| format!("Failed to open URL: {e}"))?;
|
.map_err(|e| AppError::internal(format!("Failed to open URL: {e}")))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue