You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt""errors""github.com/kashifkhan0771/utils/errutils"
)
funcmain() {
// Create a new error aggregatoragg:=errutils.NewErrorAggregator()
// Add errors to the aggregatoragg.Add(errors.New("First error"))
agg.Add(errors.New("Second error"))
agg.Add(errors.New("Third error"))
// Retrieve the aggregated erroriferr:=agg.Error(); err!=nil {
fmt.Println("Aggregated Error:", err)
}
}
Output:
Aggregated Error: First error; Second error; Third error
Check if there are any errors
package main
import (
"fmt""errors""github.com/kashifkhan0771/utils/errutils"
)
funcmain() {
// Create a new error aggregatoragg:=errutils.NewErrorAggregator()
// Add an erroragg.Add(errors.New("First error"))
// Check if there are any errorsifagg.HasErrors() {
fmt.Println("There are errors")
} else {
fmt.Println("No errors")
}
}