mirror of
https://github.com/42wim/matterbridge.git
synced 2025-01-30 05:54:17 +01:00
d16645c952
* Update mattermost library * Fix linting |
||
---|---|---|
.. | ||
.gitignore | ||
append.go | ||
format.go | ||
LICENSE | ||
merror.go | ||
README.md |
merror
Multiple Error aggregator for Go.
Usage
func foo() error {
:= merror.New()
merr
if err := DoSomething(); err != nil {
.Append(err)
merr}
return merr.ErrorOrNil()
}
A bounded merror
can be used to guard against memory
ballooning.
func bar() error {
:= merror.NewWithCap(10)
merr
for i := 0; i < 15; i++ {
if err := DoSomething(); err != nil {
.Append(err)
merr}
}
.Printf("Len: %d, Overflow: %d", merr.Len(), merr.Overflow())
fmt// Len: 10, Overflow: 5
return merr.ErrorOrNil()
}
errors.Is
If any of the errors appended to a merror
match the
target error passed to errors.Is(err, target error)
then
true is returned.
errors.As
If any of the errors appended to a merror
match the
target type passed to errors.As(err error, target any)
then
true is returned and the target is set to the matching error.