Improve exception handling

This commit is contained in:
Stefan Müller 2023-09-25 00:11:12 +02:00
parent 52085ca145
commit b014163813

View file

@ -17,25 +17,24 @@ const loadEtherpadInformations = () => {
return axios.get('https://static.etherpad.org/info.json', {headers: headers}) return axios.get('https://static.etherpad.org/info.json', {headers: headers})
.then(async resp => { .then(async resp => {
try { infos = await resp.data;
infos = await resp.data; if (infos === undefined || infos === null) {
if (infos === undefined || infos === null) { await Promise.reject("Could not retrieve current version")
await Promise.reject("Could not retrieve current version") return
return
}
lastLoadingTime = Date.now();
return await Promise.resolve(infos);
} catch (err) {
return await Promise.reject(err);
} }
lastLoadingTime = Date.now();
return await Promise.resolve(infos);
}) })
.catch(async err => {
return await Promise.reject(err);
});
} }
exports.getLatestVersion = () => { exports.getLatestVersion = () => {
exports.needsUpdate(); exports.needsUpdate().catch();
return infos.latestVersion; return infos?.latestVersion;
}; };
exports.needsUpdate = async (cb) => { exports.needsUpdate = async (cb) => {