README.md
gno.land/p/nym-moultest123/errs
Combine several errors into one. A port of the core of uber-go/multierr (MIT), trimmed to what gno needs.
1func Combine(errs ...error) error // nil, the single error, or a *multiError
2func Errors(err error) []error // unwrap back to the flat list
Combine has three behaviours worth knowing, because they are what make it
safe to call unconditionally:
- all inputs nil gives
nil, soif err := errs.Combine(...); err != nilworks as written; - exactly one non-nil input is returned as itself, not wrapped, so a type
assertion or
errors.Isupstream still matches; - nested
*multiErrorinputs are flattened, so combining in a loop does not build a tree.
The combined error prints two ways: Error() gives one line with ; between
messages (for logs and panics), String() gives one error per line (for a
Render block).
1err1 := doSomething()
2err2 := doSomethingElse()
3if err := errs.Combine(err1, err2); err != nil {
4 return err
5}
Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.