Skip to content

Commit

Permalink
Add error handling to device delete
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
agners committed Jul 15, 2024
1 parent f70126e commit ec59caa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/panels/config/devices/ha-config-device-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ec59caa

Please sign in to comment.