#script stop execution

1 messages · Page 1 of 1 (latest)

misty pelican
#

let's move this to a thread

indigo trout
#

oh nice, I didn't know the existence of this thread feature

#

so far I think that we are on the same page. If the error option is false, then only the script where the stop step is configured will be aborted. In terms of code, we are raising an exception in the stop step, but this exception is not being thrown up (what would stop the parent script)

#

however, if the error option is true, then everything should be aborted. Unless the continue_on_error is marked as true.

#
Sometimes these errors are expected, for example, because you know the service you call can be problematic at times, and it doesn’t matter if it fails. You can set continue_on_error for those cases on such an action.
misty pelican
#

yeah, I think based on that, the expected behavior from the original issue is correct

indigo trout
#

In fact, I found this scenario with the continue_on_error enabled

    def _handle_exception(
        self, exception: Exception, continue_on_error: bool, log_exceptions: bool
    ) -> None:
        if not isinstance(exception, _HaltScript) and log_exceptions:
            self._log_exception(exception)

        if not continue_on_error:
            raise exception

        # An explicit request to stop the script has been raised.
        if isinstance(exception, _StopScript):
            raise exception

        # These are incorrect scripts, and not runtime errors that need to
        # be handled and thus cannot be stopped by `continue_on_error`.
        if isinstance(
            exception,
            (
                vol.Invalid,
                exceptions.TemplateError,
                exceptions.ServiceNotFound,
                exceptions.InvalidEntityFormatError,
                exceptions.NoEntitySpecifiedError,
                exceptions.ConditionError,
            ),
        ):
            raise exception

        # Only Home Assistant errors can be ignored.
        if not isinstance(exception, exceptions.HomeAssistantError):
            raise exception
misty pelican
#

as for how to fix it, I would have to come back to this

#

I need to get to bed

#

but hopefully someone can pick this up with you

indigo trout
#

I need to sleep as well

#

2:30AM here

#

let's rest

#

I'm not sure what is the next steps for it, who I will wait for to help me and design the best solution, and so on, but let's wait for tomorrow.