Replies: 3 comments 7 replies
-
Try catch is hard to UI and write sensible from that perspective. Additionally, this brings programming to our automation/YAML, which we really generally try to avoid. The original idea was to add an When the I have a branch here somewhere local that partly implements this (which was part of my original effort in adding |
Beta Was this translation helpful? Give feedback.
-
Following up on this, as I have also looked into solving this. My first try (home-assistant/core#97857) was just adding an additional variable to the script output if However in this PR frenck suggested to rather go with a try/except route which I started in home-assistant/core#98129. There, it was suggested to first discuss this as an architecture discussion. Should this continue here or should I create a new discussion with a proposal? To be honest, I don't see a try/catch looking much different than an if/then, with the only difference that the if part is not a condition, but a script itself. However I might be biased as I fully know what to expect from this. |
Beta Was this translation helpful? Give feedback.
-
Homey has an "on error" thingy to which actions can be assigned. Maybe it's worth looking into this for inspiration. I can see this working similar to the expandable "else" option of the "if" action. |
Beta Was this translation helpful? Give feedback.
-
I've had trouble with the backend for one of my integrations being flaky and giving 504s (in this case Nest, but it's not the only one), which has resulted in some of my automations failing. I'd love to be able to handle failures in my automations, but
continue_on_error
is insufficient because there's no way to determine if some step (or sequence of steps) failed and the failure was ignored (e.g. to backoff and retry).My proposal is to add a try/catch/finally script action that would allow a user to attempt a sequence of actions in the try, handle errors (with a script variable that captures the error message and maybe the alias of the action that failed), and do cleanup work if necessary. It would look something like:
Alternatively, one could add similar metadata to a script variable if a
continue_on_error
occurs, though I think the try/catch/finally is more robust (as it can handle whole sequences and doesn't get overwritten when a second error occurs).I'm open to helping provide an implementation but wanted to first vet the proposed solution.
Beta Was this translation helpful? Give feedback.
All reactions