Skip to content

Commit

Permalink
Update lagra.go
Browse files Browse the repository at this point in the history
  • Loading branch information
simplyYan authored Sep 15, 2023
1 parent 0919b93 commit 7ee05d6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lagra.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,25 @@ func (l *Lagra) flushLogBuffer() {
atomic.StoreInt32(&l.logCounter, 0)
}
}

type ErrorCollector struct {
errors []error
}

func New() *ErrorCollector {
return &ErrorCollector{}
}

func (ec *ErrorCollector) N(err error) {
if err != nil {
ec.errors = append(ec.errors, err)
}
}

func (ec *ErrorCollector) Handle() bool {
return len(ec.errors) > 0
}

func (ec *ErrorCollector) Errors() []error {
return ec.errors
}

0 comments on commit 7ee05d6

Please sign in to comment.