mage icon indicating copy to clipboard operation
mage copied to clipboard

Enhancement: Add function-name to error at Deps

Open opensource21 opened this issue 1 year ago • 0 comments

Describe the feature If you run multiple targets with mg.Deps(a, b, c) and a and b throws an error, it difficult to get the context.

What problem does this feature address? It's easier to find the context of the error.

Additional context

func Test() error {
    mg.Deps(a, b, c)
    fmt.Println("Test")
    return nil
}

func a() error {
    duration, _ := time.ParseDuration("1s")
    time.Sleep(duration)
    fmt.Println("a")
    return errors.New("a-err")
}

func b() error {
    duration, _ := time.ParseDuration("2s")
    time.Sleep(duration)
    fmt.Println("b")
    return errors.New("b-err")
}

func c() {
    duration, _ := time.ParseDuration("5s")
    time.Sleep(duration)
    fmt.Println("c")
}

produced

Running target: Test
Running dependency: a
Running dependency: c
Running dependency: b
a
b
c
Error: a-err
b-err

wanted

niels@lapli104:/mnt/seu/sandboxes/git_k5s/technical-base/devcluster$ mage -v Test
Running target: Test
Running dependency: c
Running dependency: a
Running dependency: b
a
b
c
Error: main.a: a-err
main.b: b-err

opensource21 avatar Jun 09 '23 15:06 opensource21