mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-10-18 05:10:16 -04:00
enhancement(notifications): add possibility to show catched error message
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
4755af4ac5
commit
1f60a7dedf
1 changed files with 9 additions and 3 deletions
|
@ -25,7 +25,11 @@ interface UiNotificationContext {
|
||||||
dispatchOptions: Partial<DispatchOptions>
|
dispatchOptions: Partial<DispatchOptions>
|
||||||
) => void
|
) => void
|
||||||
|
|
||||||
showErrorNotification: (messageI18nKey: string, messageI18nOptions?: TOptions) => (error: Error) => void
|
showErrorNotification: (
|
||||||
|
messageI18nKey: string,
|
||||||
|
messageI18nOptions?: TOptions,
|
||||||
|
showErrorMessage?: boolean
|
||||||
|
) => (error: Error) => void
|
||||||
|
|
||||||
dismissNotification: (notificationUuid: string) => void
|
dismissNotification: (notificationUuid: string) => void
|
||||||
pruneNotification: (notificationUuid: string) => void
|
pruneNotification: (notificationUuid: string) => void
|
||||||
|
@ -80,11 +84,13 @@ export const UiNotificationBoundary: React.FC<PropsWithChildren> = ({ children }
|
||||||
)
|
)
|
||||||
|
|
||||||
const showErrorNotification = useCallback(
|
const showErrorNotification = useCallback(
|
||||||
(messageI18nKey: string, messageI18nOptions: Record<string, unknown> = {}) =>
|
(messageI18nKey: string, messageI18nOptions: Record<string, unknown> = {}, showErrorMessage = false) =>
|
||||||
(error: Error): void => {
|
(error: Error): void => {
|
||||||
log.error(t(messageI18nKey, messageI18nOptions), error)
|
log.error(t(messageI18nKey, messageI18nOptions), error)
|
||||||
void dispatchUiNotification('common.errorOccurred', messageI18nKey, {
|
void dispatchUiNotification('common.errorOccurred', messageI18nKey, {
|
||||||
contentI18nOptions: messageI18nOptions,
|
contentI18nOptions: showErrorMessage
|
||||||
|
? { ...messageI18nOptions, errorMessage: error.message }
|
||||||
|
: messageI18nOptions,
|
||||||
icon: IconExclamationTriangle
|
icon: IconExclamationTriangle
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue