From 29504c884bd623d2bf06ddb23643c0688295e450 Mon Sep 17 00:00:00 2001 From: 96528025 Date: Wed, 18 Mar 2026 14:38:34 -0700 Subject: [PATCH] fix: add error handling to async clipboard handler in header.tsx Wrap the async onClick handler for copying the SVG logo in a try-catch block to handle potential failures from fetch(), res.text(), and navigator.clipboard.writeText(). Show a success toast on copy and an error toast if any step fails. Fixes #722 Co-Authored-By: Claude Sonnet 4.6 --- apps/web/src/components/header.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/header.tsx b/apps/web/src/components/header.tsx index e24486b4..7eb3c9cd 100644 --- a/apps/web/src/components/header.tsx +++ b/apps/web/src/components/header.tsx @@ -23,6 +23,7 @@ import { ContextMenuItem, ContextMenuTrigger, } from "./ui/context-menu"; +import { toast } from "sonner"; export function Header() { const [isMenuOpen, setIsMenuOpen] = useState(false); @@ -66,9 +67,14 @@ export function Header() { { - const res = await fetch(DEFAULT_LOGO_URL); - const svg = await res.text(); - await navigator.clipboard.writeText(svg); + try { + const res = await fetch(DEFAULT_LOGO_URL); + const svg = await res.text(); + await navigator.clipboard.writeText(svg); + toast.success("SVG copied to clipboard"); + } catch { + toast.error("Failed to copy SVG to clipboard"); + } }} >