Update index.html
Browse files- index.html +9 -2
index.html
CHANGED
|
@@ -433,8 +433,15 @@
|
|
| 433 |
});
|
| 434 |
|
| 435 |
if (!response.ok) {
|
| 436 |
-
|
| 437 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 438 |
}
|
| 439 |
|
| 440 |
const audioBlob = await response.blob();
|
|
|
|
| 433 |
});
|
| 434 |
|
| 435 |
if (!response.ok) {
|
| 436 |
+
let errorMessage = `API Error: ${response.status} ${response.statusText}`;
|
| 437 |
+
try {
|
| 438 |
+
const errorDetails = await response.json();
|
| 439 |
+
errorMessage = errorDetails.error || JSON.stringify(errorDetails);
|
| 440 |
+
} catch (e) {
|
| 441 |
+
// If JSON parsing fails, it's likely a plain text error (like 'Not Found')
|
| 442 |
+
errorMessage = await response.text();
|
| 443 |
+
}
|
| 444 |
+
throw new Error(errorMessage);
|
| 445 |
}
|
| 446 |
|
| 447 |
const audioBlob = await response.blob();
|