diff --git a/build/build.go b/build/build.go index 0db42f95..f8a8405d 100644 --- a/build/build.go +++ b/build/build.go @@ -309,7 +309,7 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s childTargets := calculateChildTargets(reqForNodes, opt) for k, opt := range opt { - err := func(k string) error { + err := func(k string) (err error) { opt := opt dps := drivers[k] multiDriver := len(drivers[k]) > 1 @@ -321,6 +321,12 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s } baseCtx := ctx + if multiTarget { + defer func() { + err = errors.Wrapf(err, "target %s", k) + }() + } + res := make([]*client.SolveResponse, len(dps)) eg2, ctx := errgroup.WithContext(ctx) @@ -563,6 +569,13 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s tracing.FinishWithError(span, err) } }() + + if multiTarget { + defer func() { + err = errors.Wrapf(err, "target %s", k) + }() + } + pw := progress.WithPrefix(w, "default", false) if err := eg2.Wait(); err != nil { return err