1
0
mirror of https://github.com/go-task/task.git synced 2025-06-17 00:17:51 +02:00

Adds --carry flag to enable carrying error codes from task cmds

This commit is contained in:
Bruno Delor
2022-06-02 14:22:00 +02:00
parent 5836cb1728
commit a790fb7afe
4 changed files with 22 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package task
import (
"errors"
"fmt"
"mvdan.cc/sh/v3/interp"
)
var (
@ -18,15 +19,23 @@ func (err *taskNotFoundError) Error() string {
return fmt.Sprintf(`task: Task "%s" not found`, err.taskName)
}
type taskRunError struct {
type TaskRunError struct {
taskName string
err error
}
func (err *taskRunError) Error() string {
func (err *TaskRunError) Error() string {
return fmt.Sprintf(`task: Failed to run task "%s": %v`, err.taskName, err.err)
}
func (err *TaskRunError) ExitCode() int {
if c, ok := interp.IsExitStatus(err.err); ok {
return int(c)
}
return 1
}
// MaximumTaskCallExceededError is returned when a task is called too
// many times. In this case you probably have a cyclic dependendy or
// infinite loop