mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-25 01:13:39 +10:00
feat(errors): better download manager errors + modal
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
|
import { data } from "autoprefixer";
|
||||||
import { AppStatus, type AppState } from "~/types";
|
import { AppStatus, type AppState } from "~/types";
|
||||||
|
|
||||||
export function setupHooks() {
|
export function setupHooks() {
|
||||||
@@ -18,6 +19,20 @@ export function setupHooks() {
|
|||||||
router.push("/store");
|
router.push("/store");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
listen("download_error", (event) => {
|
||||||
|
createModal(
|
||||||
|
ModalType.Notification,
|
||||||
|
{
|
||||||
|
title: "Drop encountered an error while downloading",
|
||||||
|
description: `Drop encountered an error while downloading your game: "${(
|
||||||
|
event.payload as unknown as string
|
||||||
|
).toString()}"`,
|
||||||
|
buttonText: "Close"
|
||||||
|
},
|
||||||
|
(e, c) => c()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
document.addEventListener("contextmenu", (event) => {
|
document.addEventListener("contextmenu", (event) => {
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ impl GameDownloadAgent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
error!("{}", e);
|
||||||
self.sender.send(DownloadManagerSignal::Error(e)).unwrap();
|
self.sender.send(DownloadManagerSignal::Error(e)).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -491,6 +491,10 @@ impl DownloadManagerBuilder {
|
|||||||
self.stop_and_wait_current_download();
|
self.stop_and_wait_current_download();
|
||||||
self.remove_and_cleanup_front_game(¤t_status.id); // Remove all the locks and shit, and remove from queue
|
self.remove_and_cleanup_front_game(¤t_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();
|
let mut lock = current_status.status.lock().unwrap();
|
||||||
*lock = GameDownloadStatus::Error;
|
*lock = GameDownloadStatus::Error;
|
||||||
self.set_status(DownloadManagerStatus::Error(error));
|
self.set_status(DownloadManagerStatus::Error(error));
|
||||||
|
|||||||
@@ -46,12 +46,10 @@ impl ProcessManager<'_> {
|
|||||||
(Platform::Linux, Platform::Linux),
|
(Platform::Linux, Platform::Linux),
|
||||||
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
||||||
),
|
),
|
||||||
/*
|
|
||||||
(
|
(
|
||||||
(Platform::Linux, Platform::Windows),
|
(Platform::Linux, Platform::Windows),
|
||||||
&UMULauncher {} as &(dyn ProcessHandler + Sync + Send + 'static)
|
&UMULauncher {} as &(dyn ProcessHandler + Sync + Send + 'static)
|
||||||
)
|
)
|
||||||
*/
|
|
||||||
]),
|
]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
|
error::Error,
|
||||||
fmt::{Display, Formatter},
|
fmt::{Display, Formatter},
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
};
|
};
|
||||||
@@ -26,7 +27,16 @@ pub enum RemoteAccessError {
|
|||||||
impl Display for RemoteAccessError {
|
impl Display for RemoteAccessError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
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) => {
|
RemoteAccessError::ParsingError(parse_error) => {
|
||||||
write!(f, "{}", parse_error)
|
write!(f, "{}", parse_error)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user