| 1 | // Copyright (c) The EfficientGo Authors. |
| 2 | // Licensed under the Apache License 2.0. |
| 3 | |
| 4 | // Package merrors implements multi error implementation that chains errors on the same level. |
| 5 | // Supports errors.As and errors.Is functions. |
| 6 | // |
| 7 | // Example 1: |
| 8 | // |
| 9 | // return merrors.New(err1, err2).Err() |
| 10 | // |
| 11 | // Example 2: |
| 12 | // |
| 13 | // merr := merrors.New(err1) |
| 14 | // merr.Add(err2, errOrNil3) |
| 15 | // for _, err := range errs { |
| 16 | // merr.Add(err) |
| 17 | // } |
| 18 | // return merr.Err() |
| 19 | // |
| 20 | // Example 3: |
| 21 | // |
| 22 | // func CloseAll(closers []io.Closer) error { |
| 23 | // errs := merrors.New() |
| 24 | // for _ , c := range closers { |
| 25 | // errs.Add(c.Close()) |
| 26 | // } |
| 27 | // return errs.Err() |
| 28 | // } |
| 29 | package merrors |