From 942151da9dfbf544ec9cdd3b791526433491fc09 Mon Sep 17 00:00:00 2001 From: Gorniaky Date: Sat, 28 Dec 2024 23:08:42 -0300 Subject: [PATCH] fix(Command): throw error when no apps are found fix(error): improve error handling in error event feat(i18n): add message for no apps found in localization files --- l10n/bundle.l10n.json | 1 + l10n/bundle.l10n.pt.json | 1 + src/events/error.ts | 4 ++-- src/structures/Command.ts | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index a5c3f2b8..c4a2eba2 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -69,6 +69,7 @@ "more": "More", "network": "Network", "n.more": "{n} more...", + "no.apps.found.to.choose": "No apps found, please upload before that.", "noappfound": "No app found.", "offline": "Offline", "ok": "Ok", diff --git a/l10n/bundle.l10n.pt.json b/l10n/bundle.l10n.pt.json index 36b45fa8..75d370b6 100644 --- a/l10n/bundle.l10n.pt.json +++ b/l10n/bundle.l10n.pt.json @@ -69,6 +69,7 @@ "more": "Mais", "network": "Rede", "n.more": "Mais {n}...", + "no.apps.found.to.choose": "Nenhuma aplicação encontrada, por favor, faça upload antes disso.", "noappfound": "Nenhuma aplicação encontrada.", "offline": "Desligado", "ok": "Ok", diff --git a/src/events/error.ts b/src/events/error.ts index f3a69f67..208d4967 100644 --- a/src/events/error.ts +++ b/src/events/error.ts @@ -1,9 +1,9 @@ import { window } from "vscode"; import extension from "../extension"; -extension.on("error", async (error: any) => { +extension.on("error", async function (error: any) { const message = error?.body?.message ?? error; extension.logger.error(message); - window.showErrorMessage(message); + await window.showErrorMessage(error.message ?? message); }); diff --git a/src/structures/Command.ts b/src/structures/Command.ts index 834c8dae..97d639a8 100644 --- a/src/structures/Command.ts +++ b/src/structures/Command.ts @@ -125,6 +125,8 @@ export default abstract class Command { const appsLength = apps.length; const teamAppsLength = teamApps.length; + if (!appsLength && !teamAppsLength) throw new Error(t("no.apps.found.to.choose")); + const dConfig = new DiscloudConfig(extension.workspaceFolder!); let hasApp = false;