github.com/joselitofilho/goreleaser@v0.155.1-0.20210123221854-e4891856c593/internal/middleware/error.go (about)

     1  package middleware
     2  
     3  import (
     4  	"github.com/apex/log"
     5  	"github.com/goreleaser/goreleaser/internal/pipe"
     6  	"github.com/goreleaser/goreleaser/pkg/context"
     7  )
     8  
     9  // ErrHandler handles an action error, ignoring and logging pipe skipped
    10  // errors.
    11  func ErrHandler(action Action) Action {
    12  	return func(ctx *context.Context) error {
    13  		var err = action(ctx)
    14  		if err == nil {
    15  			return nil
    16  		}
    17  		if pipe.IsSkip(err) {
    18  			log.WithError(err).Warn("pipe skipped")
    19  			return nil
    20  		}
    21  		return err
    22  	}
    23  }