more verbose error handling

This commit is contained in:
Jakub Trávník 2025-12-01 14:42:52 +01:00
parent 55e8f2e2d3
commit 8e7e1694d5

View file

@ -61,7 +61,8 @@ async function exportFromApi(endpoint: string, filename: string, options: Export
const res = await fetch(url, { credentials: "include" });
if (!res.ok) {
throw new Error(`Export failed: ${res.statusText}`);
const errorText = await res.text().catch(() => res.statusText);
throw new Error(errorText || `HTTP ${res.status}`);
}
const data = await res.json();