From 9b3e4f27a54d4c2242f8f542a9eff3bba39ed9d1 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 24 Aug 2023 19:50:17 -0300 Subject: [PATCH] fix(tabsContext.tsx): handle error message properly when saving changes in the tabs provider The error handling in the tabs provider has been improved to display a more meaningful error message when there is an error while saving changes. Instead of directly assigning the error to the `setErrorData` state variable, the error message is now wrapped in an object with a title and a list of error messages. This change ensures that the error message is displayed consistently and provides better context to the user. --- src/frontend/src/contexts/tabsContext.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index 5c48e6e5b..2e3334f5e 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -30,6 +30,7 @@ import { import { getRandomDescription, getRandomName } from "../utils/utils"; import { alertContext } from "./alertContext"; import { typesContext } from "./typesContext"; +import { AxiosError } from "axios"; const uid = new ShortUniqueId({ length: 5 }); @@ -602,7 +603,7 @@ export function TabsProvider({ children }: { children: ReactNode }) { }); } } catch (err) { - setErrorData(err as errorsVarType); + setErrorData({title: "Error while saving changes",list:[(err as AxiosError).message]}); } }