From 26d27671201a844bb7b8dc2e5d9571102de1c023 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Tue, 14 Oct 2025 03:57:17 +0000 Subject: [PATCH] Coerce remaining toast variants (lib) cgen-f665641441ae43f985cd5062ce48c6b9 --- client/lib/aethex-toast.ts | 45 +++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/client/lib/aethex-toast.ts b/client/lib/aethex-toast.ts index f4ecbffe..39a81dc6 100644 --- a/client/lib/aethex-toast.ts +++ b/client/lib/aethex-toast.ts @@ -30,27 +30,66 @@ export const aethexToast = { }, error: (options: AethexToastOptions) => { + const normalize = (d?: any) => { + if (d == null) return undefined; + if (typeof d === "string") return d; + if (typeof d === "object") { + if ((d as any).message) return String((d as any).message); + try { + return JSON.stringify(d); + } catch (e) { + return String(d); + } + } + return String(d); + }; return toast({ title: `⚡ ${options.title || "Error"}`, - description: options.description, + description: normalize(options.description), duration: options.duration || 5000, variant: "destructive", }); }, warning: (options: AethexToastOptions) => { + const normalize = (d?: any) => { + if (d == null) return undefined; + if (typeof d === "string") return d; + if (typeof d === "object") { + if ((d as any).message) return String((d as any).message); + try { + return JSON.stringify(d); + } catch (e) { + return String(d); + } + } + return String(d); + }; return toast({ title: `⚠️ ${options.title || "Warning"}`, - description: options.description, + description: normalize(options.description), duration: options.duration || 5000, variant: "warning" as any, }); }, info: (options: AethexToastOptions) => { + const normalize = (d?: any) => { + if (d == null) return undefined; + if (typeof d === "string") return d; + if (typeof d === "object") { + if ((d as any).message) return String((d as any).message); + try { + return JSON.stringify(d); + } catch (e) { + return String(d); + } + } + return String(d); + }; return toast({ title: `ℹ️ ${options.title || "Information"}`, - description: options.description, + description: normalize(options.description), duration: options.duration || 5000, variant: "info" as any, });