mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-02 00:27:49 +01:00
Show errors loading automation config (#30158)
* Show errors loading automation config * Update src/panels/config/automation/ha-automation-editor.ts Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com> * prettier --------- Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
This commit is contained in:
@@ -674,6 +674,19 @@ export class HaAutomationEditor extends AutomationScriptEditorMixin<AutomationCo
|
||||
this.config = normalizeAutomationConfig(config);
|
||||
this._checkValidation();
|
||||
} catch (err: any) {
|
||||
if (err.status_code !== 404) {
|
||||
const alertText =
|
||||
err.body?.message || err.error || err.body || "Unknown error";
|
||||
await showAlertDialog(this, {
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.automation.editor.load_error_unknown",
|
||||
{ err_no: err.status_code ?? "unknown" }
|
||||
),
|
||||
text: html`<pre>${alertText}</pre>`,
|
||||
});
|
||||
goBack("/config");
|
||||
return;
|
||||
}
|
||||
const entity = this._entityRegistry.find(
|
||||
(ent) =>
|
||||
ent.platform === "automation" && ent.unique_id === this.automationId
|
||||
@@ -685,15 +698,9 @@ export class HaAutomationEditor extends AutomationScriptEditorMixin<AutomationCo
|
||||
return;
|
||||
}
|
||||
await showAlertDialog(this, {
|
||||
text:
|
||||
err.status_code === 404
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.automation.editor.load_error_not_editable"
|
||||
)
|
||||
: this.hass.localize(
|
||||
"ui.panel.config.automation.editor.load_error_unknown",
|
||||
{ err_no: err.status_code }
|
||||
),
|
||||
text: this.hass.localize(
|
||||
"ui.panel.config.automation.editor.load_error_not_editable"
|
||||
),
|
||||
});
|
||||
goBack("/config");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user