feat(errors): better download manager errors + modal

This commit is contained in:
DecDuck
2024-12-26 12:56:54 +11:00
parent 85a08990c3
commit ad92dbec08
5 changed files with 31 additions and 3 deletions

View File

@ -297,6 +297,7 @@ impl GameDownloadAgent {
}
}
Err(e) => {
error!("{}", e);
self.sender.send(DownloadManagerSignal::Error(e)).unwrap();
}
}

View File

@ -491,6 +491,10 @@ impl DownloadManagerBuilder {
self.stop_and_wait_current_download();
self.remove_and_cleanup_front_game(&current_status.id); // Remove all the locks and shit, and remove from queue
self.app_handle
.emit("download_error", error.to_string())
.unwrap();
let mut lock = current_status.status.lock().unwrap();
*lock = GameDownloadStatus::Error;
self.set_status(DownloadManagerStatus::Error(error));

View File

@ -46,12 +46,10 @@ impl ProcessManager<'_> {
(Platform::Linux, Platform::Linux),
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
),
/*
(
(Platform::Linux, Platform::Windows),
&UMULauncher {} as &(dyn ProcessHandler + Sync + Send + 'static)
)
*/
]),
}
}

View File

@ -1,4 +1,5 @@
use std::{
error::Error,
fmt::{Display, Formatter},
sync::{Arc, Mutex},
};
@ -26,7 +27,16 @@ pub enum RemoteAccessError {
impl Display for RemoteAccessError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
RemoteAccessError::FetchError(error) => write!(f, "{}", error),
RemoteAccessError::FetchError(error) => write!(
f,
"{}: {}",
error,
error
.source()
.map(|e| e.to_string())
.or_else(|| Some("Unknown error".to_string()))
.unwrap()
),
RemoteAccessError::ParsingError(parse_error) => {
write!(f, "{}", parse_error)
}