ikraamkb commited on
Commit
f6a994f
·
verified ·
1 Parent(s): 0fa2f87

Update static/appS.js

Browse files
Files changed (1) hide show
  1. static/appS.js +10 -4
static/appS.js CHANGED
@@ -168,10 +168,16 @@ document.addEventListener('DOMContentLoaded', () => {
168
  body: formData
169
  });
170
 
171
- if (!response.ok) {
172
- const error = await response.json();
173
- throw new Error(error.detail || 'Request failed');
174
- }
 
 
 
 
 
 
175
 
176
  const result = await response.json();
177
  thinkingBubble.remove();
 
168
  body: formData
169
  });
170
 
171
+ if (!response.ok) {
172
+ let errorMessage = 'Request failed';
173
+ try {
174
+ const error = await response.json();
175
+ errorMessage = error.detail || error.error || errorMessage;
176
+ } catch (e) {
177
+ // Response wasn't valid JSON
178
+ }
179
+ throw new Error(errorMessage);
180
+ }
181
 
182
  const result = await response.json();
183
  thinkingBubble.remove();