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

@@ -19,7 +19,7 @@ import DialogActions from '@mui/material/DialogActions';
import TextField from '@mui/material/TextField';
import Link from '@mui/material/Link';
import { jsonrepair } from 'jsonrepair';
import { jsonSaveParse } from '@/lib/HelperFunctions.ts';
import { getErrorMessage, jsonSaveParse } from '@/lib/HelperFunctions.ts';
import { AppTheme, isThemeNameUnique } from '@/modules/theme/services/AppThemes.ts';
import {
createUpdateMetadataServerSettings,
@@ -203,10 +203,11 @@ export const ThemeCreationDialog = ({
);
bindDialogProps.onClose(e);
})
.catch(() =>
.catch((updateError) =>
makeToast(
t(dialogModeToTranslationKey[mode].failure, { theme: theme.getName() }),
'error',
getErrorMessage(updateError),
),
)
.finally(() => setIsCreating(false));

View File

@@ -21,6 +21,7 @@ import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts'
import { CreateThemeButton } from '@/modules/theme/components/CreateThemeButton.tsx';
import { ThemePreview } from '@/modules/theme/components/ThemePreview.tsx';
import { MetadataThemeSettings } from '@/modules/theme/AppTheme.types.ts';
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
export const ThemeList = () => {
const { t } = useTranslation();
@@ -80,10 +81,11 @@ export const ThemeList = () => {
'success',
),
)
.catch(() =>
.catch((e) =>
makeToast(
t('settings.appearance.theme.delete.failure', { theme: theme.getName() }),
'error',
getErrorMessage(e),
),
);
}}

View File

@@ -25,6 +25,7 @@ import { createTheme } from '@/modules/theme/services/ThemeCreator.ts';
import { ThemeCreationDialog } from '@/modules/theme/components/CreateThemeDialog.tsx';
import { makeToast } from '@/modules/core/utils/Toast.ts';
import { TypographyMaxLines } from '@/modules/core/components/TypographyMaxLines.tsx';
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
const ThemePreviewBadge = styled(Box)(() => ({
width: '15px',
@@ -93,7 +94,13 @@ export const ThemePreview = ({ theme, onDelete }: { theme: AppTheme; onDelete: (
makeToast(t('settings.appearance.theme.select.fonts.loading'), 'info');
loadThemeFonts(theme.muiTheme)
.then(() => setAppTheme(theme.id))
.catch(() => makeToast(t('settings.appearance.theme.select.fonts.error'), 'error'));
.catch((e) =>
makeToast(
t('settings.appearance.theme.select.fonts.error'),
'error',
getErrorMessage(e),
),
);
}}
>
<Stack sx={{ height: '100%', m: 0 }}>