Spaces:
Running
Running
Show structured inference errors
Browse files- index.html +6 -1
index.html
CHANGED
|
@@ -131,7 +131,12 @@
|
|
| 131 |
stream: true,
|
| 132 |
}),
|
| 133 |
});
|
| 134 |
-
if (!response.ok)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
const reader = response.body.getReader();
|
| 137 |
const decoder = new TextDecoder();
|
|
|
|
| 131 |
stream: true,
|
| 132 |
}),
|
| 133 |
});
|
| 134 |
+
if (!response.ok) {
|
| 135 |
+
const errorBody = await response.text();
|
| 136 |
+
let message = errorBody;
|
| 137 |
+
try { message = JSON.parse(errorBody).error?.message || errorBody; } catch {}
|
| 138 |
+
throw new Error(message || `HTTP ${response.status}`);
|
| 139 |
+
}
|
| 140 |
|
| 141 |
const reader = response.body.getReader();
|
| 142 |
const decoder = new TextDecoder();
|