mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-25 02:35:39 +03:00
Better error handling for image desc generator
400 doesn't throw error
This commit is contained in:
parent
9cffd429b0
commit
7223baaaad
1 changed files with 8 additions and 1 deletions
|
@ -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?.();
|
||||
|
|
Loading…
Reference in a new issue