#script stop execution
1 messages · Page 1 of 1 (latest)
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.
yeah, I think based on that, the expected behavior from the original issue is correct
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