Removed a nested try/catch that wasn't displaying all the informations.

Kept the outside try/catch that had better logging.
This commit is contained in:
Marc-Andre Ferland 2022-10-11 16:42:27 -04:00
parent d6d4ce0ac4
commit 548149de8e

View File

@ -487,13 +487,15 @@ async function doMakeImage(task) {
let finalJSON = ''
let prevTime = -1
while (true) {
try {
let t = new Date().getTime()
const {value, done} = await reader.read()
if (done && !finalJSON && !value) {
break
}
let timeTaken = (prevTime === -1 ? -1 : t - prevTime)
let jsonStr = textDecoder.decode(value)
let jsonStr = (value ? textDecoder.decode(value) : '')
try {
// hack for a middleman buffering all the streaming updates, and unleashing them on the poor browser in one shot.
// this results in having to parse JSON like {"step": 1}{"step": 2}...{"status": "succeeded"..}
@ -544,13 +546,7 @@ async function doMakeImage(task) {
} else {
finalJSON = jsonStr
}
prevTime = t
} catch (e) {
logError('Stable Diffusion had an error. Please check the logs in the command-line window.', res, outputMsg)
res = undefined
throw e
}
}
if (!res || res.status != 200 || !stepUpdate) {
@ -585,11 +581,10 @@ async function doMakeImage(task) {
logError('Stable Diffusion had an error. Please check the logs in the command-line window. <br/><br/>' + e + '<br/><pre>' + e.stack + '</pre>', res, outputMsg)
setStatus('request', 'error', 'error')
progressBar.style.display = 'none'
res = undefined
}
if (!stepUpdate) return false
if (!stepUpdate || stepUpdate.status !== 'succeeded') {
return false
}
lastPromptUsed = reqBody['prompt']
showImages(reqBody, stepUpdate, outputContainer, false)