1
0
mirror of https://github.com/go-task/task.git synced 2024-12-04 10:24:45 +02:00

Better error message on task run error

This commit is contained in:
Andrey Nering 2017-02-26 21:23:38 -03:00
parent b2621a8bc3
commit 6104b42368

11
task.go
View File

@ -34,6 +34,15 @@ func (err *TaskNotFoundError) Error() string {
return fmt.Sprintf(`Task "%s" not found`, err.taskName)
}
type TaskRunError struct {
taskName string
err error
}
func (err *TaskRunError) Error() string {
return fmt.Sprintf(`Failed to run task "%s": %v`, err.taskName, err.err)
}
func main() {
log.SetFlags(0)
@ -76,7 +85,7 @@ func RunTask(name string) error {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return err
return &TaskRunError{name, err}
}
}
return nil