Skip to content

Commit

Permalink
fix(sentence): Catch error from custom outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
zachowj committed Jul 12, 2023
1 parent 48ebdd8 commit 867289a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/nodes/sentence/SentenceController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import OutputController, {
} from '../../common/controllers/OutputController';
import { IntegrationEvent } from '../../common/integration/Integration';
import { NodeMessage } from '../../types/nodes';
import { EntityConfigNode } from '../entity-config';
import { SentenceNode } from '.';

interface SentenceResponse {
Expand All @@ -13,8 +12,6 @@ interface SentenceResponse {
type SentenceNodeOptions = OutputControllerOptions<SentenceNode>;

export default class SentenseController extends OutputController<SentenceNode> {
#entityConfigNode?: EntityConfigNode;

constructor(props: SentenceNodeOptions) {
super(props);

Expand All @@ -27,10 +24,16 @@ export default class SentenseController extends OutputController<SentenceNode> {
#onReceivedMessage(data: SentenceResponse) {
this.status.setSuccess('home-assistant.status.triggered');
const message: NodeMessage = {};
this.setCustomOutputs(this.node.config.outputProperties, message, {
config: this.node.config,
triggerId: data.sentence,
});
try {
this.setCustomOutputs(this.node.config.outputProperties, message, {
config: this.node.config,
triggerId: data.sentence,
});
} catch (e) {
this.node.error(e);
this.status.setFailed('error');
return;
}
this.node.send(message);
}
}

0 comments on commit 867289a

Please sign in to comment.