more verbose error handling
This commit is contained in:
parent
55e8f2e2d3
commit
8e7e1694d5
1 changed files with 2 additions and 1 deletions
|
|
@ -61,7 +61,8 @@ async function exportFromApi(endpoint: string, filename: string, options: Export
|
||||||
const res = await fetch(url, { credentials: "include" });
|
const res = await fetch(url, { credentials: "include" });
|
||||||
|
|
||||||
if (!res.ok) {
|
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();
|
const data = await res.json();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue