From d390f20d635ad3529814c33f938a23b3b623db35 Mon Sep 17 00:00:00 2001 From: Phil Bracikowski Date: Mon, 19 Aug 2024 21:22:04 -0700 Subject: [PATCH] chore: improve error notifications in annotations and notebooks I noticed that annotations and notebooks could display the api error when requests fail - they are not consistent about it. --- src/annotations/components/annotationForm/AnnotationForm.tsx | 2 +- src/flows/context/flow.list.tsx | 5 +++-- src/shared/copy/notifications/categories/notebooks.ts | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/annotations/components/annotationForm/AnnotationForm.tsx b/src/annotations/components/annotationForm/AnnotationForm.tsx index 2b6fe207c6..ae1df2de08 100644 --- a/src/annotations/components/annotationForm/AnnotationForm.tsx +++ b/src/annotations/components/annotationForm/AnnotationForm.tsx @@ -140,7 +140,7 @@ export const AnnotationForm: FC = (props: Props) => { } try { - dispatch(deleteAnnotations(editedAnnotation)) + await dispatch(deleteAnnotations(editedAnnotation)) event(`annotations.delete_annotation.success`, { prefix: props.eventPrefix, }) diff --git a/src/flows/context/flow.list.tsx b/src/flows/context/flow.list.tsx index 802334f7d3..f9b54f4e7a 100644 --- a/src/flows/context/flow.list.tsx +++ b/src/flows/context/flow.list.tsx @@ -34,6 +34,7 @@ import { } from 'src/shared/copy/notifications' import {setCloneName} from 'src/utils/naming' import {CLOUD} from 'src/shared/constants' +import {getErrorMessage} from 'src/utils/api' export interface FlowListContextType extends FlowList { add: (flow?: Flow) => Promise @@ -238,8 +239,8 @@ export const FlowListProvider: FC = ({children}) => { return flow.id }) - .catch(() => { - dispatch(notify(notebookCreateFail())) + .catch(err => { + dispatch(notify(notebookCreateFail(getErrorMessage(err)))) }) } diff --git a/src/shared/copy/notifications/categories/notebooks.ts b/src/shared/copy/notifications/categories/notebooks.ts index c98b8c684b..45389a97b4 100644 --- a/src/shared/copy/notifications/categories/notebooks.ts +++ b/src/shared/copy/notifications/categories/notebooks.ts @@ -21,9 +21,9 @@ export const panelCopyLinkFail = (): Notification => ({ message: `Failed to copy the panel link`, }) -export const notebookCreateFail = (): Notification => ({ +export const notebookCreateFail = (error: string): Notification => ({ ...defaultErrorNotification, - message: `Failed to create Notebook, please try again.`, + message: `Failed to create Notebook, please try again: ${error}`, }) export const notebookUpdateFail = (): Notification => ({