Ignore error if we are not connected (#8472)

This commit is contained in:
Joakim Sørensen 2021-02-26 21:37:06 +01:00 committed by GitHub
parent 0bc2eb530d
commit 01e4414d17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 12 deletions

View File

@ -159,7 +159,11 @@ export class HassioUpdate extends LitElement {
} catch (err) { } catch (err) {
// Only show an error if the status code was not expected (user behind proxy) // Only show an error if the status code was not expected (user behind proxy)
// or no status at all(connection terminated) // or no status at all(connection terminated)
if (err.status_code && !ignoredStatusCodes.has(err.status_code)) { if (
this.hass.connection.connected &&
err.status_code &&
!ignoredStatusCodes.has(err.status_code)
) {
showAlertDialog(this, { showAlertDialog(this, {
title: "Update failed", title: "Update failed",
text: extractApiErrorMessage(err), text: extractApiErrorMessage(err),

View File

@ -130,9 +130,11 @@ class DialogSupervisorCoreUpdate extends LitElement {
try { try {
await updateCore(this.hass); await updateCore(this.hass);
} catch (err) { } catch (err) {
this._error = extractApiErrorMessage(err); if (this.hass.connection.connected) {
this._action = null; this._error = extractApiErrorMessage(err);
return; this._action = null;
return;
}
} }
fireEvent(this, "supervisor-colllection-refresh", { colllection: "core" }); fireEvent(this, "supervisor-colllection-refresh", { colllection: "core" });
this.closeDialog(); this.closeDialog();

View File

@ -140,10 +140,12 @@ class HassioCoreInfo extends LitElement {
try { try {
await restartCore(this.hass); await restartCore(this.hass);
} catch (err) { } catch (err) {
showAlertDialog(this, { if (this.hass.connection.connected) {
title: "Failed to restart Home Assistant Core", showAlertDialog(this, {
text: extractApiErrorMessage(err), title: "Failed to restart Home Assistant Core",
}); text: extractApiErrorMessage(err),
});
}
} finally { } finally {
button.progress = false; button.progress = false;
} }

View File

@ -342,10 +342,12 @@ class HassioHostInfo extends LitElement {
await updateOS(this.hass); await updateOS(this.hass);
fireEvent(this, "supervisor-colllection-refresh", { colllection: "os" }); fireEvent(this, "supervisor-colllection-refresh", { colllection: "os" });
} catch (err) { } catch (err) {
showAlertDialog(this, { if (this.hass.connection.connected) {
title: "Failed to update", showAlertDialog(this, {
text: extractApiErrorMessage(err), title: "Failed to update",
}); text: extractApiErrorMessage(err),
});
}
} }
button.progress = false; button.progress = false;
} }