Return 502 with error description when connection to remote CC API fails

If chat-completions/generate returns an error, throw the error message

Reformat display of exceptions during SD prompt text generation
This commit is contained in:
ceruleandeep
2024-11-22 11:51:05 +11:00
parent 0383ea52e9
commit 8de551fc94
3 changed files with 15 additions and 6 deletions

View File

@ -2432,8 +2432,12 @@ async function generatePicture(initiator, args, trigger, message, callback) {
imagePath = await sendGenerationRequest(generationType, prompt, negativePromptPrefix, characterName, callback, initiator, abortController.signal);
} catch (err) {
console.trace(err);
toastr.error('SD prompt text generation failed. Reason: ' + err, 'Image Generation');
throw new Error('SD prompt text generation failed. Reason: ' + err);
// errors here are most likely due to text generation failure
// sendGenerationRequest mostly deals with its own errors
const reason = err.error?.message || err.message || 'Unknown error';
const errorText = 'SD prompt text generation failed. ' + reason;
toastr.error(errorText, 'Image Generation');
throw new Error(errorText);
}
finally {
$(stopButton).hide();