From 22084284cc9a4b0d3403265ff0c6014feba2b9fe Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Tue, 14 Oct 2025 03:56:27 +0000 Subject: [PATCH] Improve error extraction in AuthContext.updateProfile cgen-e18475d3240f4393bdc0d8a65ff14d10 --- client/contexts/AuthContext.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/client/contexts/AuthContext.tsx b/client/contexts/AuthContext.tsx index 16560d11..692db53e 100644 --- a/client/contexts/AuthContext.tsx +++ b/client/contexts/AuthContext.tsx @@ -713,11 +713,23 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ }); } catch (error: any) { setProfile((prev) => ({ ...(prev || ({} as any)), ...updates }) as any); + const extractErrorMessage = (err: any) => { + if (!err) return "Failed to update profile. Please try again."; + if (typeof err === "string") return err; + if (err.message) return err.message; + try { + return JSON.stringify(err); + } catch (e) { + return String(err); + } + }; + const msg = extractErrorMessage(error); aethexToast.error({ title: "Update failed", - description: error.message, + description: msg, }); - throw error; + // Throw a normalized Error to give callers a searchable message + throw new Error(msg); } };