mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Ignore disconnect codes for shutdown and reboot (#6901)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
c06357a351
commit
fa65f84e09
@ -16,6 +16,7 @@ import "../../../src/components/ha-svg-icon";
|
|||||||
import {
|
import {
|
||||||
extractApiErrorMessage,
|
extractApiErrorMessage,
|
||||||
HassioResponse,
|
HassioResponse,
|
||||||
|
ignoredStatusCodes,
|
||||||
} from "../../../src/data/hassio/common";
|
} from "../../../src/data/hassio/common";
|
||||||
import { HassioHassOSInfo } from "../../../src/data/hassio/host";
|
import { HassioHassOSInfo } from "../../../src/data/hassio/host";
|
||||||
import {
|
import {
|
||||||
@ -166,7 +167,7 @@ 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 && ![502, 503, 504].includes(err.status_code)) {
|
if (err.status_code && !ignoredStatusCodes.has(err.status_code)) {
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
title: "Update failed",
|
title: "Update failed",
|
||||||
text: extractApiErrorMessage(err),
|
text: extractApiErrorMessage(err),
|
||||||
|
@ -19,7 +19,10 @@ import "../../../src/components/buttons/ha-progress-button";
|
|||||||
import "../../../src/components/ha-button-menu";
|
import "../../../src/components/ha-button-menu";
|
||||||
import "../../../src/components/ha-card";
|
import "../../../src/components/ha-card";
|
||||||
import "../../../src/components/ha-settings-row";
|
import "../../../src/components/ha-settings-row";
|
||||||
import { extractApiErrorMessage } from "../../../src/data/hassio/common";
|
import {
|
||||||
|
extractApiErrorMessage,
|
||||||
|
ignoredStatusCodes,
|
||||||
|
} from "../../../src/data/hassio/common";
|
||||||
import { fetchHassioHardwareInfo } from "../../../src/data/hassio/hardware";
|
import { fetchHassioHardwareInfo } from "../../../src/data/hassio/hardware";
|
||||||
import {
|
import {
|
||||||
changeHostOptions,
|
changeHostOptions,
|
||||||
@ -245,10 +248,13 @@ class HassioHostInfo extends LitElement {
|
|||||||
try {
|
try {
|
||||||
await rebootHost(this.hass);
|
await rebootHost(this.hass);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showAlertDialog(this, {
|
// Ignore connection errors, these are all expected
|
||||||
title: "Failed to reboot",
|
if (err.status_code && !ignoredStatusCodes.has(err.status_code)) {
|
||||||
text: extractApiErrorMessage(err),
|
showAlertDialog(this, {
|
||||||
});
|
title: "Failed to reboot",
|
||||||
|
text: extractApiErrorMessage(err),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
button.progress = false;
|
button.progress = false;
|
||||||
}
|
}
|
||||||
@ -272,10 +278,13 @@ class HassioHostInfo extends LitElement {
|
|||||||
try {
|
try {
|
||||||
await shutdownHost(this.hass);
|
await shutdownHost(this.hass);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showAlertDialog(this, {
|
// Ignore connection errors, these are all expected
|
||||||
title: "Failed to shutdown",
|
if (err.status_code && !ignoredStatusCodes.has(err.status_code)) {
|
||||||
text: extractApiErrorMessage(err),
|
showAlertDialog(this, {
|
||||||
});
|
title: "Failed to shutdown",
|
||||||
|
text: extractApiErrorMessage(err),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
button.progress = false;
|
button.progress = false;
|
||||||
}
|
}
|
||||||
|
@ -13,3 +13,5 @@ export const extractApiErrorMessage = (error: any): string => {
|
|||||||
: error.body || "Unknown error, see logs"
|
: error.body || "Unknown error, see logs"
|
||||||
: error;
|
: error;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ignoredStatusCodes = new Set([502, 503, 504]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user