Better error handling for image desc generator

400 doesn't throw error
pull/392/head
Lim Chee Aun 2024-01-06 12:23:15 +08:00
rodzic 9cffd429b0
commit 7223baaaad
1 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -1838,10 +1838,17 @@ function MediaAttachment({
method: 'POST',
body,
}).then((r) => r.json());
if (response.error) {
throw new Error(response.error);
}
setDescription(response.description);
} catch (e) {
console.error(e);
showToast('Failed to generate description');
showToast(
`Failed to generate description${
e?.message ? `: ${e.message}` : ''
}`,
);
} finally {
setUIState('default');
toastRef.current?.hideToast?.();