Add error handling

This commit is contained in:
Wendelin 2025-04-11 14:44:22 +02:00
parent 5c0279bab8
commit c33143b997
No known key found for this signature in database
2 changed files with 17 additions and 6 deletions

View File

@ -4,6 +4,7 @@ import type { CSSResultGroup } from "lit";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import "../../components/ha-alert";
import "../../components/ha-dialog-header";
import "../../components/ha-icon-button";
import "../../components/ha-md-dialog";
@ -29,6 +30,9 @@ class DialogRestartWait extends LitElement {
private _actionOnIdle?: () => Promise<void>;
@state()
private _error?: string;
@state()
private _backupState?: ManagerState;
@ -97,8 +101,16 @@ class DialogRestartWait extends LitElement {
<span slot="title" .title=${this._title}> ${this._title} </span>
</ha-dialog-header>
<div slot="content" class="content">
<ha-spinner></ha-spinner>
${waitMessage}
${this._error
? html`<ha-alert alert-type="error"
>${this.hass.localize("ui.dialogs.restart.error_backup_state", {
error: this._error,
})}</ha-alert
> `
: html`
<ha-spinner></ha-spinner>
${waitMessage}
`}
</div>
</ha-md-dialog>
`;
@ -125,10 +137,8 @@ class DialogRestartWait extends LitElement {
}
}
);
} catch (err) {
// TODO show error to user
// eslint-disable-next-line no-console
console.error(err);
} catch (err: any) {
this._error = err.message || err;
}
}

View File

@ -1543,6 +1543,7 @@
"upload_in_progress": "A backup upload is currently in progress. The action will automatically proceed once the upload process is complete.",
"restore_in_progress": "A backup restore is currently in progress. The action will automatically proceed once the restore process is complete.",
"wait_for_backup": "Wait for the backup creation to finish",
"error_backup_state": "An error occured while getting the current backup state. Error: {error}",
"wait_for_upload": "Wait for backup upload to finish",
"wait_for_restore": "Wait for backup restore to finish",
"reload": {