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,7 +17,6 @@ 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")
@ -26,16 +25,16 @@ const loadEtherpadInformations = () => {
lastLoadingTime = Date.now(); lastLoadingTime = Date.now();
return await Promise.resolve(infos); return await Promise.resolve(infos);
} catch (err) {
return await Promise.reject(err);
}
}) })
.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) => {