1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/internal/middleware/error.go
Carlos Alexandro Becker f61d8c820c
fix: improve output a bit (#2174)
* fix: improve output a bit

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: improve output a bit

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: revert unwanted changes

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: skip err

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: test

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* chore: build

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-04-19 09:31:57 -03:00

28 lines
574 B
Go

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 {
err := action(ctx)
if err == nil {
return nil
}
if pipe.IsExpectedSkip(err) {
log.WithError(err).Debug("pipe skipped")
return nil
}
if pipe.IsSkip(err) {
log.WithError(err).Warn("pipe skipped")
return nil
}
return err
}
}