From 1f60a7dedfed6119a9a2027c45bef9cfb4e5c303 Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Wed, 17 Jan 2024 15:30:18 +0100 Subject: [PATCH] enhancement(notifications): add possibility to show catched error message Signed-off-by: Erik Michelson --- .../notifications/ui-notification-boundary.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/notifications/ui-notification-boundary.tsx b/frontend/src/components/notifications/ui-notification-boundary.tsx index 785822bd2..59066c0cc 100644 --- a/frontend/src/components/notifications/ui-notification-boundary.tsx +++ b/frontend/src/components/notifications/ui-notification-boundary.tsx @@ -25,7 +25,11 @@ interface UiNotificationContext { dispatchOptions: Partial ) => void - showErrorNotification: (messageI18nKey: string, messageI18nOptions?: TOptions) => (error: Error) => void + showErrorNotification: ( + messageI18nKey: string, + messageI18nOptions?: TOptions, + showErrorMessage?: boolean + ) => (error: Error) => void dismissNotification: (notificationUuid: string) => void pruneNotification: (notificationUuid: string) => void @@ -80,11 +84,13 @@ export const UiNotificationBoundary: React.FC = ({ children } ) const showErrorNotification = useCallback( - (messageI18nKey: string, messageI18nOptions: Record = {}) => + (messageI18nKey: string, messageI18nOptions: Record = {}, showErrorMessage = false) => (error: Error): void => { log.error(t(messageI18nKey, messageI18nOptions), error) void dispatchUiNotification('common.errorOccurred', messageI18nKey, { - contentI18nOptions: messageI18nOptions, + contentI18nOptions: showErrorMessage + ? { ...messageI18nOptions, errorMessage: error.message } + : messageI18nOptions, icon: IconExclamationTriangle }) },