mirror of
https://github.com/moby/buildkit.git
synced 2026-08-05 07:10:23 +00:00
These descriptions can be useful for callers to identify which op failed and plumb any custom metadata through to those failures. Signed-off-by: Erik Sipsma <erik@sipsma.dev>
22 lines
401 B
Go
22 lines
401 B
Go
package errdefs
|
|
|
|
import "github.com/moby/buildkit/solver/pb"
|
|
|
|
type OpError struct {
|
|
error
|
|
Op *pb.Op
|
|
Description map[string]string
|
|
}
|
|
|
|
func (e *OpError) Unwrap() error {
|
|
return e.error
|
|
}
|
|
|
|
func WithOp(err error, anyOp interface{}, opDesc map[string]string) error {
|
|
op, ok := anyOp.(*pb.Op)
|
|
if err == nil || !ok {
|
|
return err
|
|
}
|
|
return &OpError{error: err, Op: op, Description: opDesc}
|
|
}
|