fix(api): improve error handling for API requests

This commit is contained in:
2026-02-08 00:20:03 +02:00
parent 252530610b
commit bc422e7d66
2 changed files with 8 additions and 0 deletions

View File

@@ -62,6 +62,10 @@ function FormerResolveSpecAPI(options: {
const response = await fetch(url, fetchOptions);
if (!response.ok) {
const text = await response.text();
if (text && text.length > 4) {
throw new Error(`${text}`);
}
throw new Error(`API request failed with status ${response.status}`);
}

View File

@@ -35,6 +35,10 @@ function FormerRestHeadSpecAPI(options: {
const response = await fetch(url, fetchOptions);
if (!response.ok) {
const text = await response.text();
if (text && text.length > 4) {
throw new Error(`${text}`);
}
throw new Error(`API request failed with status ${response.status}`);
}