mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-14 14:46:41 +10:00
feat(errors): Using SerializeDisplay for better error management with Result
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
use std::sync::Mutex;
|
||||
|
||||
use crate::{
|
||||
error::{process_error::ProcessError, user_error::UserValue},
|
||||
AppState, DB,
|
||||
error::process_error::ProcessError,
|
||||
AppState,
|
||||
};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn launch_game(
|
||||
id: String,
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
) -> UserValue<(), ProcessError> {
|
||||
) -> Result<(), ProcessError> {
|
||||
let state_lock = state.lock().unwrap();
|
||||
let mut process_manager_lock = state_lock.process_manager.lock().unwrap();
|
||||
|
||||
@@ -21,24 +21,23 @@ pub fn launch_game(
|
||||
|
||||
match process_manager_lock.launch_process(id) {
|
||||
Ok(_) => {}
|
||||
Err(e) => return UserValue::Err(e),
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
|
||||
drop(process_manager_lock);
|
||||
drop(state_lock);
|
||||
|
||||
UserValue::Ok(())
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn kill_game(
|
||||
game_id: String,
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
) -> UserValue<(), ProcessError> {
|
||||
) -> Result<(), ProcessError> {
|
||||
let state_lock = state.lock().unwrap();
|
||||
let mut process_manager_lock = state_lock.process_manager.lock().unwrap();
|
||||
process_manager_lock
|
||||
.kill_game(game_id)
|
||||
.map_err(ProcessError::IOError)
|
||||
.into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user