mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Improve robustness of automation editor description error handling (#21993)
This commit is contained in:
parent
1cdfb746bf
commit
3079f126a8
@ -68,9 +68,18 @@ export const describeTrigger = (
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entityRegistry: EntityRegistryEntry[],
|
entityRegistry: EntityRegistryEntry[],
|
||||||
ignoreAlias = false
|
ignoreAlias = false
|
||||||
) => {
|
): string => {
|
||||||
try {
|
try {
|
||||||
return tryDescribeTrigger(trigger, hass, entityRegistry, ignoreAlias);
|
const description = tryDescribeTrigger(
|
||||||
|
trigger,
|
||||||
|
hass,
|
||||||
|
entityRegistry,
|
||||||
|
ignoreAlias
|
||||||
|
);
|
||||||
|
if (typeof description !== "string") {
|
||||||
|
throw new Error(String(description));
|
||||||
|
}
|
||||||
|
return description;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -700,9 +709,18 @@ export const describeCondition = (
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entityRegistry: EntityRegistryEntry[],
|
entityRegistry: EntityRegistryEntry[],
|
||||||
ignoreAlias = false
|
ignoreAlias = false
|
||||||
) => {
|
): string => {
|
||||||
try {
|
try {
|
||||||
return tryDescribeCondition(condition, hass, entityRegistry, ignoreAlias);
|
const description = tryDescribeCondition(
|
||||||
|
condition,
|
||||||
|
hass,
|
||||||
|
entityRegistry,
|
||||||
|
ignoreAlias
|
||||||
|
);
|
||||||
|
if (typeof description !== "string") {
|
||||||
|
throw new Error(String(description));
|
||||||
|
}
|
||||||
|
return description;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
@ -50,7 +50,7 @@ export const describeAction = <T extends ActionType>(
|
|||||||
ignoreAlias = false
|
ignoreAlias = false
|
||||||
): string => {
|
): string => {
|
||||||
try {
|
try {
|
||||||
return tryDescribeAction(
|
const description = tryDescribeAction(
|
||||||
hass,
|
hass,
|
||||||
entityRegistry,
|
entityRegistry,
|
||||||
labelRegistry,
|
labelRegistry,
|
||||||
@ -59,6 +59,10 @@ export const describeAction = <T extends ActionType>(
|
|||||||
actionType,
|
actionType,
|
||||||
ignoreAlias
|
ignoreAlias
|
||||||
);
|
);
|
||||||
|
if (typeof description !== "string") {
|
||||||
|
throw new Error(String(description));
|
||||||
|
}
|
||||||
|
return description;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user