Skip to content

Commit a33c2b0

Browse files
committed
Update readme
1 parent 9709736 commit a33c2b0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎README.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ errors.Is(outer, ErrNotFound) // true
115115

116116
### Collecting
117117

118+
A `MultiError` collects errors into a single `error`. It is safe for concurrent use, so goroutines can add to one
119+
collection without extra locking.
120+
118121
```go
119122
errs := errors.NewMulti()
120123
errs.Add(process(1), process(2)) // nils are skipped
@@ -186,8 +189,9 @@ Full reference: [pkg.go.dev][link-go-dev-reference].
186189

187190
## Differences from the standard library
188191

189-
- `errors.Unwrap` returns `nil` for an `*Error`, since it unwraps to its underlying error and its cause; use `Is` and
190-
`As`.
192+
- `errors.Unwrap` returns `nil` for every `*Error`, as it does for `errors.Join`: it only follows `Unwrap() error`,
193+
and `*Error` implements `Unwrap() []error` to expose both its underlying error and its cause. Use `Is` and `As`, or
194+
walk `Unwrap() []error`.
191195
- `New` returns `*Error`, so `err := errors.New("x")` declares an `*Error` that can't be assigned a plain `error`
192196
later.
193197
- Package-level `New` errors report package initialization as their stack trace; turn them into `Sentinel`s.

0 commit comments

Comments
 (0)