Add error handling to device delete (#21403)

Currently, if device delete fails, the frontend stays silent. The
user might get hints in the Core logs, but nothing shown on the
frontend.

This adds error handling similar to other places.
This commit is contained in:
Stefan Agner 2024-07-18 19:50:46 +01:00 committed by GitHub
parent 219f548261
commit d997cfcef0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View File

@ -999,11 +999,20 @@ export class HaConfigDevicePage extends LitElement {
return;
}
await removeConfigEntryFromDevice(
this.hass!,
this.deviceId,
entry.entry_id
);
try {
await removeConfigEntryFromDevice(
this.hass!,
this.deviceId,
entry.entry_id
);
} catch (err: any) {
showAlertDialog(this, {
title: this.hass.localize(
"ui.panel.config.devices.error_delete"
),
text: err.message,
});
}
},
classes: "warning",
icon: mdiDelete,

View File

@ -4068,6 +4068,7 @@
"delete": "Delete",
"confirm_delete": "Are you sure you want to delete this device?",
"confirm_delete_integration": "Are you sure you want to remove this device from {integration}?",
"error_delete": "Error deleting device",
"picker": {
"search": "Search {number} devices",
"state": "State",