Fix streaming processor error handler hooks

This commit is contained in:
Cohee
2023-12-08 02:01:08 +02:00
parent 055d6c4337
commit b0e7b73a32
6 changed files with 42 additions and 25 deletions

View File

@@ -672,8 +672,8 @@ function tryParseStreamingError(response, decoded) {
return;
}
if (data.error) {
toastr.error(data.error.message || response.statusText, 'API returned an error');
if (data.message || data.error) {
toastr.error(data.message || data.error?.message || response.statusText, 'NovelAI API');
throw new Error(data);
}
}
@@ -692,7 +692,7 @@ export async function generateNovelWithStreaming(generate_data, signal) {
signal: signal,
});
if (!response.ok) {
tryParseStreamingError(response, await response.body.text());
tryParseStreamingError(response, await response.text());
throw new Error(`Got response status ${response.status}`);
}
const eventStream = new EventSourceStream();