mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 22:26:57 +01: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',
|
method: 'POST',
|
||||||
body,
|
body,
|
||||||
}).then((r) => r.json());
|
}).then((r) => r.json());
|
||||||
|
if (response.error) {
|
||||||
|
throw new Error(response.error);
|
||||||
|
}
|
||||||
setDescription(response.description);
|
setDescription(response.description);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
showToast('Failed to generate description');
|
showToast(
|
||||||
|
`Failed to generate description${
|
||||||
|
e?.message ? `: ${e.message}` : ''
|
||||||
|
}`,
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setUIState('default');
|
setUIState('default');
|
||||||
toastRef.current?.hideToast?.();
|
toastRef.current?.hideToast?.();
|
||||||
|
|
Loading…
Reference in a new issue