Toowired commited on
Commit
b0a02f2
·
verified ·
1 Parent(s): 0c399fb

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +9 -2
index.html CHANGED
@@ -433,8 +433,15 @@
433
  });
434
 
435
  if (!response.ok) {
436
- const error = await response.json();
437
- throw new Error(error.error || 'Failed to fetch audio from API.');
 
 
 
 
 
 
 
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();