Improve Horde request error detection

This commit is contained in:
Cohee
2023-08-27 13:31:14 +03:00
parent 56f13b6966
commit 109ea4008b
2 changed files with 18 additions and 5 deletions

View File

@@ -4202,8 +4202,15 @@ app.post('/generate_horde', jsonParser, async (request, response) => {
const data = await postAsync(url, args);
return response.send(data);
} catch (error) {
console.error(error);
return response.sendStatus(500);
console.log('Horde returned an error:', error.statusText);
if (typeof error.text === 'function') {
const message = await error.text();
console.log(message);
return response.send({ error: { message } });
} else {
return response.send({ error: true });
}
}
});