github.com/pdmccormick/importable-docker-buildx@v0.0.0-20240426161518-e47091289030/controller/errdefs/build.go (about) 1 package errdefs 2 3 import ( 4 "github.com/containerd/typeurl/v2" 5 "github.com/moby/buildkit/util/grpcerrors" 6 ) 7 8 func init() { 9 typeurl.Register((*Build)(nil), "github.com/docker/buildx", "errdefs.Build+json") 10 } 11 12 type BuildError struct { 13 Build 14 error 15 } 16 17 func (e *BuildError) Unwrap() error { 18 return e.error 19 } 20 21 func (e *BuildError) ToProto() grpcerrors.TypedErrorProto { 22 return &e.Build 23 } 24 25 func WrapBuild(err error, ref string) error { 26 if err == nil { 27 return nil 28 } 29 return &BuildError{Build: Build{Ref: ref}, error: err} 30 } 31 32 func (b *Build) WrapError(err error) error { 33 return &BuildError{error: err, Build: *b} 34 }