containers / build

another build tool for container images (archived, see https://github.com/rkt/rkt/issues/4024)
Apache License 2.0
342 stars 80 forks source link

lib/run: better error output when dependency doesn't exist #287

Closed cgonyeo closed 7 years ago

cgonyeo commented 7 years ago

If fetching a dependency for a run command, and the registry returns a 404 error, intercept that and print a more user-friendly error saying that the dependency doesn't exist.

Example:

derek@proton 1 ~/go/src/github.com/containers/build> sudo ./bin/acbuild run -- apk update
run: dependency "quay.io/coreos/alpine-sh:doesnt-exist" doesn't appear to exist: bad HTTP status code: 404

Fixes https://github.com/containers/build/issues/283

cgonyeo commented 7 years ago

I don't particularly like this implementation due to the .Error() == "string" check, but as far as I can tell the error at that point is just created via an errors.New(), so I don't know what else I have to work with.

I say this because fmt.Printf("#%T\n") resulted in an *errors.errorString.

lucab commented 7 years ago

@s-urbaniak can you please have a review pass on this?

cgonyeo commented 7 years ago

Yup, I like your implementation a lot better. Just pushed your changes.