debug: include server response in client error

cgen-29bf43e54beb4c27a72b49a2071475bf
This commit is contained in:
Builder.io 2025-09-28 04:14:24 +00:00
parent 234ef0fea8
commit 11ffddcf39

View file

@ -137,8 +137,11 @@ export default function Onboarding() {
body: JSON.stringify({ id: user.id, profile: payload }),
});
if (!ensureResp.ok) {
const j = await ensureResp.json().catch(() => ({}));
throw new Error(j.error || "Failed to save profile");
const text = await ensureResp.text().catch(() => "");
let parsedError: any = undefined;
try { parsedError = JSON.parse(text); } catch {}
const message = parsedError?.error || text || `HTTP ${ensureResp.status}`;
throw new Error(message);
}
// Fire-and-forget interests via server