Merge pull request #626 from Zagrios/bugfix/download-from-steam-all-errors-are-unknown-errors

[bugfix] Fixed all errors from depotdownloader was unknown errors
This commit is contained in:
MathieuG-P
2024-10-22 22:09:28 +02:00
committed by GitHub
3 changed files with 8 additions and 6 deletions
@@ -12,6 +12,7 @@ import { DepotDownloaderArgsOptions, DepotDownloaderErrorEvent, DepotDownloaderE
import { DepotDownloader } from "../../models/depot-downloader.class";
import { app } from "electron";
import { BsStore } from "../../../shared/models/bs-store.enum";
import { CustomError } from "shared/models/exceptions/custom-error.class";
export class BsSteamDownloaderService {
private static instance: BsSteamDownloaderService;
@@ -96,7 +97,7 @@ export class BsSteamDownloaderService {
depotDownloader.$events().pipe(
map(event => {
if(event.type === DepotDownloaderEventType.Error){
throw event;
throw new CustomError(JSON.stringify(event.data) ?? "An error occur in the DepotDownloader process", event?.subType ?? DepotDownloaderErrorEvent.Unknown, event)
}
return event;
}),
@@ -4,7 +4,7 @@ import { useTranslation } from "renderer/hooks/use-translation.hook";
import { ModalComponent, ModalExitCode, ModalService } from "renderer/services/modale.service";
import { WhySteamCredentialsModal } from "./why-steam-credentials-modal.component";
import { useService } from "renderer/hooks/use-service.hook";
import { Observable } from "rxjs";
import { catchError, Observable, of } from "rxjs";
import { useObservable } from "renderer/hooks/use-observable.hook";
import { QRCodeSVG } from "qrcode.react";
import { BsmCheckbox } from "renderer/components/shared/bsm-checkbox.component";
@@ -21,7 +21,7 @@ export const LoginToSteamModal: ModalComponent<
const [password, setPassword] = useState("");
const [stay, setStay] = useState(false);
const [showPassword, setShowPassword] = useState(false);
const qrCodeUrl = useObservable(() => data.qrCode$);
const qrCodeUrl = useObservable(() => data.qrCode$.pipe(catchError(() => of(null))));
const t = useTranslation();
useEffect(() => {
@@ -13,6 +13,7 @@ import { SteamMobileApproveModal } from "renderer/components/modal/modal-types/b
import { DownloaderServiceInterface } from "./bs-store-downloader.interface";
import { AbstractBsDownloaderService } from "./abstract-bs-downloader.service";
import { addFilterStringLog } from "renderer";
import { CustomError } from "shared/models/exceptions/custom-error.class";
export class SteamDownloaderService extends AbstractBsDownloaderService implements DownloaderServiceInterface{
@@ -120,11 +121,11 @@ export class SteamDownloaderService extends AbstractBsDownloaderService implemen
return subs;
}
private hanndleErrorEvent(errorEvent: DepotDownloaderEvent) {
private hanndleErrorEvent(errorEvent: CustomError) {
const handledErrors = Object.values(DepotDownloaderErrorEvent);
if(handledErrors.includes(errorEvent?.subType as DepotDownloaderErrorEvent)){
return this.notificationService.notifyError({title: "notifications.types.error", desc: `notifications.bs-download.steam-download.errors.msg.${errorEvent.subType}`, duration: 10_000});
if(handledErrors.includes(errorEvent?.code as DepotDownloaderErrorEvent)){
return this.notificationService.notifyError({title: "notifications.types.error", desc: `notifications.bs-download.steam-download.errors.msg.${errorEvent.code}`, duration: 10_000});
}
return this.notificationService.notifyError({title: "notifications.types.error", desc: `notifications.bs-download.steam-download.errors.msg.${DepotDownloaderErrorEvent.Unknown}`, duration: 10_000});