Skip to content

Commit

Permalink
fix(Command): throw error when no apps are found
Browse files Browse the repository at this point in the history
fix(error): improve error handling in error event

feat(i18n): add message for no apps found in localization files
  • Loading branch information
Gorniaky committed Dec 29, 2024
1 parent d2d56fa commit 942151d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions l10n/bundle.l10n.pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/events/error.ts
Original file line number Diff line number Diff line change
@@ -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);
});
2 changes: 2 additions & 0 deletions src/structures/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 942151d

Please sign in to comment.