close
Skip to content

There should be a way to exit from a task with an error message without a traceback #269

@frol

Description

@frol

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions