UI fixes
This commit is contained in:
@@ -31,8 +31,15 @@ async function request<T>(
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json().catch(() => ({ error: 'Request failed' }));
|
||||
throw new Error(error.error || 'Request failed');
|
||||
const body = await response.text();
|
||||
let errorMsg = 'Request failed';
|
||||
try {
|
||||
const error = JSON.parse(body);
|
||||
errorMsg = error.error || error.message || body;
|
||||
} catch {
|
||||
errorMsg = body || errorMsg;
|
||||
}
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
|
||||
Reference in New Issue
Block a user