Handle config flow errors better (#11499)

* Handle config flow errors better

* Use body for error message

* Update dialog-data-entry-flow.ts
This commit is contained in:
Bram Kragten 2022-02-01 11:22:14 +01:00 committed by GitHub
parent fb55ab197f
commit 54d6b5b6f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,15 +116,14 @@ class DataEntryFlowDialog extends LitElement {
params.continueFlowId
);
} catch (err: any) {
this._step = undefined;
this._params = undefined;
this.closeDialog();
showAlertDialog(this, {
title: this.hass.localize(
"ui.panel.config.integrations.config_flow.error"
),
text: this.hass.localize(
text: `${this.hass.localize(
"ui.panel.config.integrations.config_flow.could_not_load"
),
)}: ${err.message || err.body}`,
});
return;
}
@ -177,6 +176,7 @@ class DataEntryFlowDialog extends LitElement {
});
}
this._loading = undefined;
this._step = undefined;
this._params = undefined;
this._devices = undefined;
@ -372,15 +372,14 @@ class DataEntryFlowDialog extends LitElement {
try {
step = await this._params!.flowConfig.createFlow(this.hass, handler);
} catch (err: any) {
this._step = undefined;
this._params = undefined;
this.closeDialog();
showAlertDialog(this, {
title: this.hass.localize(
"ui.panel.config.integrations.config_flow.error"
),
text: this.hass.localize(
text: `${this.hass.localize(
"ui.panel.config.integrations.config_flow.could_not_load"
),
)}: ${err.message || err.body}`,
});
return;
} finally {
@ -405,6 +404,15 @@ class DataEntryFlowDialog extends LitElement {
this._loading = "loading_step";
try {
this._step = await step;
} catch (err: any) {
this.closeDialog();
showAlertDialog(this, {
title: this.hass.localize(
"ui.panel.config.integrations.config_flow.error"
),
text: err.message || err.body,
});
return;
} finally {
this._loading = undefined;
}