Include actual error in snackbar

This commit is contained in:
schroda
2024-12-20 17:24:40 +01:00
parent 91a1f75de6
commit 3949363474
44 changed files with 292 additions and 91 deletions

View File

@@ -32,6 +32,7 @@ import {
INSTALLED_STATE_TO_TRANSLATION_KEY_MAP,
} from '@/modules/extension/Extensions.constants.ts';
import { getInstalledState } from '@/modules/extension/Extensions.utils.ts';
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
interface IProps {
extension: TExtension;
@@ -84,7 +85,11 @@ export function ExtensionCard(props: IProps) {
handleUpdate();
} catch (e) {
setInstalledState(getInstalledState(isInstalled, isObsolete, hasUpdate));
makeToast(t(EXTENSION_ACTION_TO_FAILURE_TRANSLATION_KEY_MAP[action], { count: 1 }), 'error');
makeToast(
t(EXTENSION_ACTION_TO_FAILURE_TRANSLATION_KEY_MAP[action], { count: 1 }),
'error',
getErrorMessage(e),
);
}
};

View File

@@ -40,6 +40,7 @@ import {
import { ExtensionAction, ExtensionGroupState, ExtensionState } from '@/modules/extension/Extensions.types.ts';
import { EXTENSION_ACTION_TO_FAILURE_TRANSLATION_KEY_MAP } from '@/modules/extension/Extensions.constants.ts';
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
const LANGUAGE = 0;
const EXTENSIONS = 1;
@@ -123,7 +124,7 @@ export function Extensions({ tabsMenuHeight }: { tabsMenuHeight: number }) {
handleExtensionUpdate();
makeToast(t('extension.label.installed_successfully'), 'success');
})
.catch(() => makeToast(t('extension.label.installation_failed'), 'error'));
.catch((e) => makeToast(t('extension.label.installation_failed'), 'error', getErrorMessage(e)));
} else {
makeToast(t('global.error.label.invalid_file_type'), 'error');
}
@@ -263,7 +264,7 @@ export function Extensions({ tabsMenuHeight }: { tabsMenuHeight: number }) {
requestManager
.updateExtensions(extensionIds, { update: true })
.response.then(() => handleExtensionUpdate())
.catch(() =>
.catch((e) =>
makeToast(
t(
EXTENSION_ACTION_TO_FAILURE_TRANSLATION_KEY_MAP[
@@ -271,6 +272,8 @@ export function Extensions({ tabsMenuHeight }: { tabsMenuHeight: number }) {
],
{ count: groupedExtensions.length },
),
'error',
getErrorMessage(e),
),
)
.finally(() => setUpdatingExtensionIds([]));