-
Notifications
You must be signed in to change notification settings - Fork 8
/
err_handlers.go
31 lines (24 loc) · 949 Bytes
/
err_handlers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package errhandlers
import (
"github.com/hashicorp/go-multierror"
"github.com/rotisserie/eris"
"github.com/solo-io/skv2/contrib/pkg/sets"
"github.com/solo-io/skv2/pkg/ezkube"
)
// this file contains ErrorHandlers for handling errors created when writing output snapshots
type AppendingErrHandler struct {
errs error
}
func (a AppendingErrHandler) HandleWriteError(resource ezkube.Object, err error) {
a.errs = multierror.Append(a.errs, eris.Wrapf(err, "writing resource %v failed", sets.Key(resource)))
}
func (a AppendingErrHandler) HandleDeleteError(resource ezkube.Object, err error) {
a.errs = multierror.Append(a.errs, eris.Wrapf(err, "deleting resource %v failed", sets.Key(resource)))
}
func (a AppendingErrHandler) HandleListError(err error) {
a.errs = multierror.Append(a.errs, eris.Wrapf(err, "listing failed"))
}
// returns the errors collected by the handler
func (a AppendingErrHandler) Errors() error {
return a.errs
}