From ea19740f5a7bb84878856b96fecfd899cd8081d4 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 17 Mar 2022 13:44:06 -0700 Subject: [PATCH] Ignore diagnostics not found exceptions (#12066) --- .../config/devices/ha-config-device-page.ts | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/panels/config/devices/ha-config-device-page.ts b/src/panels/config/devices/ha-config-device-page.ts index 54d926b978..b1b8064359 100644 --- a/src/panels/config/devices/ha-config-device-page.ts +++ b/src/panels/config/devices/ha-config-device-page.ts @@ -33,6 +33,7 @@ import { fetchDiagnosticHandler, getDeviceDiagnosticsDownloadUrl, getConfigEntryDiagnosticsDownloadUrl, + DiagnosticInfo, } from "../../../data/diagnostics"; import { EntityRegistryEntry, @@ -219,22 +220,32 @@ export class HaConfigDevicePage extends LitElement { } let links = await Promise.all( - this._integrations(device, this.entries).map(async (entry) => { - if (entry.state !== "loaded") { - return false; - } - const info = await fetchDiagnosticHandler(this.hass, entry.domain); + this._integrations(device, this.entries).map( + async (entry): Promise => { + if (entry.state !== "loaded") { + return false; + } + let info: DiagnosticInfo; + try { + info = await fetchDiagnosticHandler(this.hass, entry.domain); + } catch (err: any) { + if (err.code === "not_found") { + return false; + } + throw err; + } - if (!info.handlers.device && !info.handlers.config_entry) { - return false; + if (!info.handlers.device && !info.handlers.config_entry) { + return false; + } + return { + link: info.handlers.device + ? getDeviceDiagnosticsDownloadUrl(entry.entry_id, this.deviceId) + : getConfigEntryDiagnosticsDownloadUrl(entry.entry_id), + domain: entry.domain, + }; } - return { - link: info.handlers.device - ? getDeviceDiagnosticsDownloadUrl(entry.entry_id, this.deviceId) - : getConfigEntryDiagnosticsDownloadUrl(entry.entry_id), - domain: entry.domain, - }; - }) + ) ); links = links.filter(Boolean);