mage icon indicating copy to clipboard operation
mage copied to clipboard

Enhancement: Add function-name to error at Deps

Open opensource21 opened this issue 2 years ago • 2 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

This enhancement would be a great quality of life improvement, but the MR associated to it seems to have stalled: is there any reason why, and is there something that could be done to get it approved (I did not see any discussion about it in the mage channel in the gophers slack, but maybe I missed it)? I'd be more than willing to re-create an up-to-date MR if @opensource21 does not have the time to rebase their branch 👍

marene avatar Nov 21 '24 14:11 marene

I can make the rebase, but without any feedback it looks like waste of time.

opensource21 avatar Nov 21 '24 19:11 opensource21