add try catch alert to imageGen
This commit is contained in:
@@ -195,6 +195,7 @@ export function AddImage({
|
||||
className="bg-sky-400 m-1 p-1 rounded disabled:bg-slate-500"
|
||||
disabled={imageGenGenerating}
|
||||
onClick={async () => {
|
||||
try {
|
||||
setImageGenGenerating(true);
|
||||
const body: any = {
|
||||
prompt: imageGenPrompt,
|
||||
@@ -217,6 +218,7 @@ export function AddImage({
|
||||
body: JSON.stringify(body),
|
||||
}).then((resp) => resp.json())
|
||||
).data;
|
||||
console.log("image gen resp", resp);
|
||||
|
||||
for (const image of resp) {
|
||||
let url = "";
|
||||
@@ -247,9 +249,12 @@ export function AddImage({
|
||||
|
||||
setChatStore({ ...chatStore });
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert("Failed to generate image: " + e);
|
||||
} finally {
|
||||
setImageGenGenerating(false);
|
||||
console.log("image resp", resp);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{Tr("Generate")}
|
||||
|
||||
Reference in New Issue
Block a user