What am I doing wrong?
func (m *Tests) CaptureErrorRepro(ctx context.Context) (*dagger.File, error) {
ctr, err := dag.Container().From("alpine:latest").
WithExec([]string{"sh", "-c", "echo 'foobar' > /tmp/foo"}).
WithExec([]string{"sh", "-c", "exit 1"}).
Sync(ctx)
if err != nil {
return nil, fmt.Errorf("expected error captured: %w", err)
}
return ctr.File("/tmp/foo"), nil
}
I want to capture any errors before returning something else, but that basic example shows how the error is never captured after the Sync(ctx)
dagger call -m pocs/tests capture-error-repro
✔ connect 0.2s
✔ load module: pocs/tests 0.7s
✔ parsing command line arguments 0.0s
✔ tests: Tests! 1.5s
✘ .captureErrorRepro: File! 0.5s ERROR
├╴✔ container: Container! 0.0s
├╴$ .from(address: "alpine:latest"): Container! 0.2s CACHED
├╴$ withExec sh -c 'echo '\''foobar'\'' > /tmp/foo' 0.0s CACHED
╰╴✘ withExec sh -c 'exit 1' 0.2s ERROR
! exit code: 1
What am I missing?
Seems like it's not capturing the error at the Sync()
Has this always worked this way?