From d997cfcef0a2f7e42a8a2270300a15855bb80308 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 18 Jul 2024 19:50:46 +0100 Subject: [PATCH] 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. --- .../config/devices/ha-config-device-page.ts | 19 ++++++++++++++----- src/translations/en.json | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/panels/config/devices/ha-config-device-page.ts b/src/panels/config/devices/ha-config-device-page.ts index 1a9809b9b6..fb691cc7e0 100644 --- a/src/panels/config/devices/ha-config-device-page.ts +++ b/src/panels/config/devices/ha-config-device-page.ts @@ -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, diff --git a/src/translations/en.json b/src/translations/en.json index 4302e553af..afe034cf79 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -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",