copier icon indicating copy to clipboard operation
copier copied to clipboard

raise a specific exception when a task fails

Open tsvikas opened this issue 11 months ago • 2 comments

Actual Situation

when a task fails, copier raises subprocess.CalledProcessError.

Desired Situation

raise a specific exception, such as TaskFailed this will allow user or external tools that run copier to separate between exceptions caused by tasks, and those caused by code issues.

Proposed solution

in copier/main.py:369, replace the subprocess internal check with code that checks the return code and raises TaskFailed with the task command and task returncode.

I can write the code if needed.

tsvikas avatar Feb 27 '25 13:02 tsvikas

Sounds good to me. :+1: Please feel free to submit a PR.

Perhaps we can call the exception TaskError?

sisp avatar Feb 27 '25 13:02 sisp

i can go with any name :). notice that if the task is a linter / checker, it might return 1 when it means "i found issues in your code" and not "i failed to run"

tsvikas avatar Feb 27 '25 13:02 tsvikas