mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 16:22:43 +10:00
feat(errors): Using SerializeDisplay for better error management with Result
This commit is contained in:
@ -4,7 +4,7 @@ use tauri::AppHandle;
|
||||
|
||||
use crate::{
|
||||
error::{
|
||||
library_error::LibraryError, remote_access_error::RemoteAccessError, user_error::UserValue,
|
||||
library_error::LibraryError, remote_access_error::RemoteAccessError,
|
||||
},
|
||||
games::library::{get_current_meta, uninstall_game_logic},
|
||||
AppState,
|
||||
@ -19,16 +19,16 @@ use super::{
|
||||
};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn fetch_library(app: AppHandle) -> UserValue<Vec<Game>, RemoteAccessError> {
|
||||
fetch_library_logic(app).into()
|
||||
pub fn fetch_library(app: AppHandle) -> Result<Vec<Game>, RemoteAccessError> {
|
||||
fetch_library_logic(app)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn fetch_game(
|
||||
game_id: String,
|
||||
app: tauri::AppHandle,
|
||||
) -> UserValue<FetchGameStruct, RemoteAccessError> {
|
||||
fetch_game_logic(game_id, app).into()
|
||||
) -> Result<FetchGameStruct, RemoteAccessError> {
|
||||
fetch_game_logic(game_id, app)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@ -37,21 +37,21 @@ pub fn fetch_game_status(id: String) -> GameStatusWithTransient {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn uninstall_game(game_id: String, app_handle: AppHandle) -> UserValue<(), LibraryError> {
|
||||
pub fn uninstall_game(game_id: String, app_handle: AppHandle) -> Result<(), LibraryError> {
|
||||
let meta = match get_current_meta(&game_id) {
|
||||
Some(data) => data,
|
||||
None => return UserValue::Err(LibraryError::MetaNotFound(game_id)),
|
||||
None => return Err(LibraryError::MetaNotFound(game_id)),
|
||||
};
|
||||
println!("{:?}", meta);
|
||||
uninstall_game_logic(meta, &app_handle);
|
||||
|
||||
UserValue::Ok(())
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn fetch_game_verion_options(
|
||||
game_id: String,
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
) -> UserValue<Vec<GameVersionOption>, RemoteAccessError> {
|
||||
fetch_game_verion_options_logic(game_id, state).into()
|
||||
) -> Result<Vec<GameVersionOption>, RemoteAccessError> {
|
||||
fetch_game_verion_options_logic(game_id, state)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user