I am validating some arguments inside of a task and I want to exit gracefully with an error message.
Digging into the code showed that it only handles invoke.exceptions.Failure in https://github.com/pyinvoke/invoke/blob/master/invoke/cli.py#L432
At this point, I worked around this with the following hack:
import logging
from invoke.exceptions import Failure
from invoke.runner import Result
class ConfigError(Failure):
def __init__(self, msg):
logging.error(msg)
super(ConfigError, self).__init__(
Result(stdout='', stderr='', exited=1, pty=None)
)
and then I can
raise ConfigError("my error message")
But I would rather prefer to have a built-in Invoke exception that will just exit with an error and exit code.
I am validating some arguments inside of a task and I want to exit gracefully with an error message.
Digging into the code showed that it only handles
invoke.exceptions.Failurein https://github.com/pyinvoke/invoke/blob/master/invoke/cli.py#L432At this point, I worked around this with the following hack:
and then I can
But I would rather prefer to have a built-in Invoke exception that will just exit with an error and exit code.