mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2024-11-28 19:23:14 +01:00
Report errors if Stable Diffusion failed to generate an image
This commit is contained in:
parent
c1c876e12d
commit
83e3288177
21
index.html
21
index.html
@ -119,6 +119,12 @@ async function makeImage() {
|
||||
|
||||
let outputMsg = document.querySelector('#outputMsg')
|
||||
|
||||
function logError(msg, res) {
|
||||
outputMsg.innerHTML = '<span style="color: red">Error: ' + msg + '</span>'
|
||||
console.log('request error', res)
|
||||
setStatus('request', 'error', 'error')
|
||||
}
|
||||
|
||||
let reqBody = {
|
||||
prompt: document.querySelector('#prompt').value,
|
||||
num_outputs: document.querySelector('#num_outputs').value,
|
||||
@ -139,19 +145,24 @@ async function makeImage() {
|
||||
},
|
||||
body: JSON.stringify(reqBody)
|
||||
})
|
||||
|
||||
if (res.status != 200) {
|
||||
logError('Stable Diffusion had an error: ' + await res.text() + '. This happens some times. Maybe modify the prompt or seed a bit?', res)
|
||||
res = undefined
|
||||
} else {
|
||||
res = await res.json()
|
||||
|
||||
if (res.status !== 'succeeded') {
|
||||
let msg = ''
|
||||
if (res.detail !== undefined) {
|
||||
outputMsg.innerHTML = 'Error: ' + res.detail[0].msg + " in " + JSON.stringify(res.detail[0].loc)
|
||||
msg = res.detail[0].msg + " in " + JSON.stringify(res.detail[0].loc)
|
||||
} else {
|
||||
outputMsg.innerHTML = 'Error: ' + res
|
||||
msg = res
|
||||
}
|
||||
outputMsg.innerHTML = '<span style="color: red">' + outputMsg.innerHTML + '</span>'
|
||||
console.log('request error', res)
|
||||
setStatus('request', 'error', 'error')
|
||||
logError(msg, res)
|
||||
res = undefined
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('request error', e)
|
||||
setStatus('request', 'error', 'error')
|
||||
|
Loading…
Reference in New Issue
Block a user