Add in some error handling/display during the install/update process.

This commit is contained in:
jliddev
2020-12-14 13:04:23 -06:00
parent 130bca9722
commit f29adf2f85
17 changed files with 51 additions and 10 deletions

View File

@@ -146,6 +146,7 @@
"protobufjs": "6.10.2",
"rxjs": "6.6.3",
"slug": "4.0.2",
"ts-custom-error": "3.2.0",
"uuid": "8.3.2"
}
}

View File

@@ -57,7 +57,8 @@ export class AddonUpdateButtonComponent implements OnInit, OnDestroy {
public getIsButtonActive() {
return (
this.listItem?.installState !== AddonInstallState.Unknown &&
this.listItem?.installState !== AddonInstallState.Complete
this.listItem?.installState !== AddonInstallState.Complete &&
this.listItem?.installState !== AddonInstallState.Error
);
}
@@ -109,6 +110,8 @@ export class AddonUpdateButtonComponent implements OnInit, OnDestroy {
return this._translateService.instant("COMMON.ADDON_STATUS.INSTALLING");
case AddonInstallState.Pending:
return this._translateService.instant("COMMON.ADDON_STATUS.PENDING");
case AddonInstallState.Error:
return this._translateService.instant("COMMON.ADDON_STATUS.ERROR");
default:
return "";
}

View File

@@ -0,0 +1 @@
export * from "./install-error";

View File

@@ -0,0 +1,7 @@
import { CustomError } from "ts-custom-error";
export class InstallError extends CustomError {
public constructor(message?: string, public addonName?: string) {
super(message);
}
}

View File

@@ -4,5 +4,6 @@ export enum AddonInstallState {
BackingUp,
Installing,
Complete,
Error,
Unknown,
}

View File

@@ -39,6 +39,7 @@ import { WarcraftService } from "../warcraft/warcraft.service";
import { WowUpService } from "../wowup/wowup.service";
import { AddonProviderFactory } from "./addon.provider.factory";
import { AddonFolder } from "../../models/wowup/addon-folder";
import { InstallError } from "../../errors";
export enum ScanUpdateType {
Start,
@@ -71,11 +72,13 @@ export class AddonService {
private readonly _addonInstalledSrc = new Subject<AddonUpdateEvent>();
private readonly _addonRemovedSrc = new Subject<string>();
private readonly _scanUpdateSrc = new BehaviorSubject<ScanUpdate>({ type: ScanUpdateType.Unknown });
private readonly _installErrorSrc = new Subject<Error>();
private readonly _installQueue = new Subject<InstallQueueItem>();
public readonly addonInstalled$ = this._addonInstalledSrc.asObservable();
public readonly addonRemoved$ = this._addonRemovedSrc.asObservable();
public readonly scanUpdate$ = this._scanUpdateSrc.asObservable();
public readonly installError$ = this._installErrorSrc.asObservable();
constructor(
private _addonStorage: AddonStorageService,
@@ -89,8 +92,14 @@ export class AddonService {
) {
this._addonProviders = addonProviderFactory.getAll();
this._installQueue.pipe(mergeMap((item) => from(this.processInstallQueue(item)), 3)).subscribe((addonName) => {
console.log("Install complete", addonName);
this._installQueue.pipe(mergeMap((item) => from(this.processInstallQueue(item)), 3)).subscribe({
next: (addonName) => {
console.log("Install complete", addonName);
},
error: (error) => {
console.error(error);
this._installErrorSrc.next(error);
},
});
// Attempt to remove addons for clients that were lost
@@ -323,6 +332,7 @@ export class AddonService {
let downloadedFilePath = "";
let unzippedDirectory = "";
try {
downloadedFilePath = await this._downloadService.downloadZipFile(
addon.downloadUrl,
@@ -395,9 +405,23 @@ export class AddonService {
this.reconcileExternalIds(addon, queueItem.originalAddon);
queueItem.completion.resolve();
onUpdate?.call(this, AddonInstallState.Complete, 100);
this._addonInstalledSrc.next({
addon,
installState: AddonInstallState.Complete,
progress: 100,
});
} catch (err) {
console.error(err);
queueItem.completion.reject(err);
onUpdate?.call(this, AddonInstallState.Error, 100);
this._addonInstalledSrc.next({
addon,
installState: AddonInstallState.Error,
progress: 100,
});
} finally {
const unzippedDirectoryExists = await this._fileService.pathExists(unzippedDirectory);
@@ -412,13 +436,6 @@ export class AddonService {
}
}
onUpdate?.call(this, AddonInstallState.Complete, 100);
this._addonInstalledSrc.next({
addon,
installState: AddonInstallState.Complete,
progress: 100,
});
return addon.name;
};

View File

@@ -46,6 +46,7 @@
"BACKINGUP": "Backup wird erstellt",
"COMPLETE": "Vollständig",
"DOWNLOADING": "Herunterladen...",
"ERROR": "Error",
"INSTALLING": "Installieren...",
"PENDING": "Ausstehend",
"UNINSTALLING": "Deinstallieren...",

View File

@@ -46,6 +46,7 @@
"BACKINGUP": "Backing Up",
"COMPLETE": "Installed",
"DOWNLOADING": "Downloading",
"ERROR": "Error",
"INSTALLING": "Installing",
"PENDING": "Pending",
"UNINSTALLING": "Uninstalling",

View File

@@ -46,6 +46,7 @@
"BACKINGUP": "Respaldando",
"COMPLETE": "Instalado",
"DOWNLOADING": "Descargando",
"ERROR": "Error",
"INSTALLING": "Instalando",
"PENDING": "Pendiente",
"UNINSTALLING": "Desinstalando",

View File

@@ -46,6 +46,7 @@
"BACKINGUP": "Sauvegarde",
"COMPLETE": "Installé",
"DOWNLOADING": "Téléchargement",
"ERROR": "Error",
"INSTALLING": "Installation",
"PENDING": "En attente",
"UNINSTALLING": "Désinstallation",

View File

@@ -46,6 +46,7 @@
"BACKINGUP": "Backup in corso",
"COMPLETE": "Installato",
"DOWNLOADING": "Download in corso",
"ERROR": "Error",
"INSTALLING": "Installazione in corso",
"PENDING": "In sospeso",
"UNINSTALLING": "Disinstallazione in corso",

View File

@@ -46,6 +46,7 @@
"BACKINGUP": "백업 중",
"COMPLETE": "설치됨",
"DOWNLOADING": "다운로드 중",
"ERROR": "Error",
"INSTALLING": "설치 중",
"PENDING": "일시정지됨",
"UNINSTALLING": "삭제 중",

View File

@@ -46,6 +46,7 @@
"BACKINGUP": "Sikkerhetskopierer",
"COMPLETE": "Installert",
"DOWNLOADING": "Laster Ned",
"ERROR": "Error",
"INSTALLING": "Installerer",
"PENDING": "Venter",
"UNINSTALLING": "Avinstallerer",

View File

@@ -46,6 +46,7 @@
"BACKINGUP": "Fazendo Backup",
"COMPLETE": "Instalado",
"DOWNLOADING": "Baixando",
"ERROR": "Error",
"INSTALLING": "Instalando",
"PENDING": "Pendente",
"UNINSTALLING": "Desinstalando",

View File

@@ -46,6 +46,7 @@
"BACKINGUP": "Резервное копирование",
"COMPLETE": "Установлена",
"DOWNLOADING": "Загружается",
"ERROR": "Error",
"INSTALLING": "Устанавливается",
"PENDING": "В ожидании",
"UNINSTALLING": "Удаляется",

View File

@@ -46,6 +46,7 @@
"BACKINGUP": "正在備份",
"COMPLETE": "已安裝",
"DOWNLOADING": "正在下載",
"ERROR": "Error",
"INSTALLING": "正在安裝",
"PENDING": "等待中",
"UNINSTALLING": "正在解除安裝",

View File

@@ -46,6 +46,7 @@
"BACKINGUP": "正在备份",
"COMPLETE": "已安装",
"DOWNLOADING": "正在下载",
"ERROR": "Error",
"INSTALLING": "正在安装",
"PENDING": "等待中",
"UNINSTALLING": "正在卸载",