From 71f7af267a397c06247c9f908613ce8156ed6e4b Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Tue, 3 Mar 2026 21:41:35 -0500 Subject: [PATCH] Add URL context to API fetch errors for easier debugging When the API server is unreachable, the raw "fetch failed" error gives no indication of what URL was being requested. Wrapping the error includes the target URL in the message while chaining the original cause. Co-Authored-By: Claude Opus 4.6 --- apps/arc-web/app/api-client.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/arc-web/app/api-client.ts b/apps/arc-web/app/api-client.ts index 0c40a5fcf..5afea2bd1 100644 --- a/apps/arc-web/app/api-client.ts +++ b/apps/arc-web/app/api-client.ts @@ -58,10 +58,12 @@ export async function apiFetch( headers.set("Authorization", `Bearer ${token}`); } - return fetch(`${base_url}${path}`, { - ...init, - headers, - }); + const url = `${base_url}${path}`; + try { + return await fetch(url, { ...init, headers }); + } catch (cause) { + throw new Error(`API request to ${url} failed`, { cause }); + } } /**