improve error messages

This commit is contained in:
josc146 2024-03-26 21:29:21 +08:00
parent 0ab248c478
commit 253568ef29
4 changed files with 10 additions and 5 deletions

View File

@ -494,7 +494,7 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
commonStore.setTracks(tracks); commonStore.setTracks(tracks);
refreshTracksTotalTime(); refreshTracksTotalTime();
} else { } else {
toast(r.statusText + '\n' + (await r.text()), { toast('Failed to fetch - ' + r.status + ' - ' + r.statusText + ' - ' + (await r.text()), {
type: 'error' type: 'error'
}); });
} }

View File

@ -608,7 +608,12 @@ const ChatPanel: FC = observer(() => {
}, },
async onopen(response) { async onopen(response) {
if (response.status !== 200) { if (response.status !== 200) {
commonStore.conversation[answerId!].content += '\n[ERROR]\n```\n' + response.statusText + '\n' + (await response.text()) + '\n```'; let errText = await response.text();
try {
errText = JSON.stringify(JSON.parse(errText), null, 2);
} catch (e) {
}
commonStore.conversation[answerId!].content += '\n[ERROR]\n```\n' + response.status + ' - ' + response.statusText + '\n' + errText + '\n```';
commonStore.setConversation(commonStore.conversation); commonStore.setConversation(commonStore.conversation);
commonStore.setConversationOrder([...commonStore.conversationOrder]); commonStore.setConversationOrder([...commonStore.conversationOrder]);
setTimeout(scrollToBottom); setTimeout(scrollToBottom);
@ -746,7 +751,7 @@ const ChatPanel: FC = observer(() => {
autoClose: 1000 autoClose: 1000
}); });
} else { } else {
toast(r.statusText + '\n' + (await r.text()), { toast('Failed to fetch - ' + r.status + ' - ' + r.statusText + ' - ' + (await r.text()), {
type: 'error' type: 'error'
}); });
} }

View File

@ -132,7 +132,7 @@ const CompletionPanel: FC = observer(() => {
}, },
async onopen(response) { async onopen(response) {
if (response.status !== 200) { if (response.status !== 200) {
toast(response.statusText + '\n' + (await response.text()), { toast(response.status + ' - ' + response.statusText + ' - ' + (await response.text()), {
type: 'error' type: 'error'
}); });
} }

View File

@ -235,7 +235,7 @@ const CompositionPanel: FC = observer(() => {
}, },
async onopen(response) { async onopen(response) {
if (response.status !== 200) { if (response.status !== 200) {
toast(response.statusText + '\n' + (await response.text()), { toast(response.status + ' - ' + response.statusText + ' - ' + (await response.text()), {
type: 'error' type: 'error'
}); });
} }