2019-01-22 01:56:16 -02:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/apex/log"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipe"
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ErrHandler handles an action error, ignoring and logging pipe skipped
|
|
|
|
// errors.
|
|
|
|
func ErrHandler(action Action) Action {
|
|
|
|
return func(ctx *context.Context) error {
|
2021-04-19 09:31:57 -03:00
|
|
|
err := action(ctx)
|
2019-01-22 01:56:16 -02:00
|
|
|
if err == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2021-04-19 09:31:57 -03:00
|
|
|
if pipe.IsExpectedSkip(err) {
|
|
|
|
log.WithError(err).Debug("pipe skipped")
|
|
|
|
return nil
|
|
|
|
}
|
2019-01-22 01:56:16 -02:00
|
|
|
if pipe.IsSkip(err) {
|
|
|
|
log.WithError(err).Warn("pipe skipped")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|