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) {
// Only show an error if the status code was not expected (user behind proxy)
// 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, {
title: "Update failed",
text: extractApiErrorMessage(err),

View File

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

View File

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

View File

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