From 7ee05d632931162e73288dd8cf67865f9f21f90b Mon Sep 17 00:00:00 2001 From: Wesley Yan Soares Brehmer <102262759+simplyYan@users.noreply.github.com> Date: Fri, 15 Sep 2023 18:29:27 -0300 Subject: [PATCH] Update lagra.go --- lagra.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lagra.go b/lagra.go index c03c763..f089140 100644 --- a/lagra.go +++ b/lagra.go @@ -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 +}