kvyb commited on
Commit
275db1e
·
verified ·
1 Parent(s): 253c5ce

Show structured inference errors

Browse files
Files changed (1) hide show
  1. index.html +6 -1
index.html CHANGED
@@ -131,7 +131,12 @@
131
  stream: true,
132
  }),
133
  });
134
- if (!response.ok) throw new Error((await response.text()) || `HTTP ${response.status}`);
 
 
 
 
 
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();