wip: displaying error in a toast

This commit is contained in:
Rohit Das 2023-12-11 15:58:49 +05:30
parent a7bec01d7b
commit 195cfd4f84
2 changed files with 140 additions and 120 deletions

View file

@ -191,6 +191,15 @@
}) })
}); });
if (!res.ok) {
const error = await res.json();
console.log(error);
if ('detail' in error) {
toast.error(error.detail);
} else {
toast.error(error.error);
}
} else {
const reader = res.body const reader = res.body
.pipeThrough(new TextDecoderStream()) .pipeThrough(new TextDecoderStream())
.pipeThrough(splitStream('\n')) .pipeThrough(splitStream('\n'))
@ -266,6 +275,7 @@
history: history history: history
}); });
} }
}
stopResponseFlag = false; stopResponseFlag = false;
await tick(); await tick();

View file

@ -218,6 +218,15 @@
}) })
}); });
if (!res.ok) {
const error = await res.json();
console.log(error);
if ('detail' in error) {
toast.error(error.detail);
} else {
toast.error(error.error);
}
} else {
const reader = res.body const reader = res.body
.pipeThrough(new TextDecoderStream()) .pipeThrough(new TextDecoderStream())
.pipeThrough(splitStream('\n')) .pipeThrough(splitStream('\n'))
@ -293,6 +302,7 @@
history: history history: history
}); });
} }
}
stopResponseFlag = false; stopResponseFlag = false;
await tick(); await tick();