[Updater > Host] Fail gracefully

This commit is contained in:
Ducko 2022-04-04 08:23:02 +01:00
parent a3aeadc9e8
commit 668235aed9
1 changed files with 4 additions and 3 deletions

View File

@ -22,17 +22,18 @@ class HostLinux extends events.EventEmitter {
try {
const current = vParse(app.getVersion());
get(this.updateUrl, (_e, res, body) => {
get(this.updateUrl, (err, res, body) => {
if (err) return this.emit('error');
if (res.statusCode === 204) return this.emit('update-not-available');
const latest = vParse(JSON.parse(body).name);
const latest = vParse(JSON.parse(body).name);
if (vNewer(latest, current)) return this.emit('update-manually', latest.join('.'));
this.emit('update-not-available');
});
} catch (e) {
log('HostLinux', 'Error', e);
this.emit('error', e);
this.emit('error');
}
}
}