Skip to content

Enhancement: Add function-name to error at Deps #472

Open

Description

@opensource21

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

Activity

  1. marene commented on Nov 21, 2024

    @marene

    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 👍

  2. opensource21 commented on Nov 21, 2024

    @opensource21
    Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions