Ignore diagnostics not found exceptions (#12066)

This commit is contained in:
Paulus Schoutsen 2022-03-17 13:44:06 -07:00 committed by GitHub
parent 5247b2813f
commit ea19740f5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,7 @@ import {
fetchDiagnosticHandler, fetchDiagnosticHandler,
getDeviceDiagnosticsDownloadUrl, getDeviceDiagnosticsDownloadUrl,
getConfigEntryDiagnosticsDownloadUrl, getConfigEntryDiagnosticsDownloadUrl,
DiagnosticInfo,
} from "../../../data/diagnostics"; } from "../../../data/diagnostics";
import { import {
EntityRegistryEntry, EntityRegistryEntry,
@ -219,22 +220,32 @@ export class HaConfigDevicePage extends LitElement {
} }
let links = await Promise.all( let links = await Promise.all(
this._integrations(device, this.entries).map(async (entry) => { this._integrations(device, this.entries).map(
if (entry.state !== "loaded") { async (entry): Promise<boolean | { link: string; domain: string }> => {
return false; if (entry.state !== "loaded") {
} return false;
const info = await fetchDiagnosticHandler(this.hass, entry.domain); }
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) { if (!info.handlers.device && !info.handlers.config_entry) {
return false; 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); links = links.filter(Boolean);