Skip to content

Commit eba8be6

Browse files
committed
Update readme
1 parent 09b370c commit eba8be6

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1414
- `MultiError.Format` implements `fmt.Formatter`: `%+v` prints every collected error with `%+v`
1515

1616
### Changed
17-
- `Wrap` and `Newf` reuse the stack trace of the first `*Error` found through single-error wrappers, and `Wrap` gives a stackless `*Error` the current stack trace
18-
- `Error.Fields` merges the fields of every `*Error` found through single-error wrappers, the outermost value winning
17+
- `Wrap`, `Newf`, `Error.Fields` and `%+v` look through single-error wrappers for inner `*Error` values: the first stack trace found is reused, fields are merged with the outermost value winning, and every cause is printed
18+
- `Wrap` gives a stackless `*Error` the current stack trace
1919
- `Error.WithCause` appends to the causes instead of replacing the cause (**breaking**)
2020
- `Error.Unwrap` returns `[]error` holding the underlying error and the causes, so `errors.Unwrap` returns nil for an `*Error` (**breaking**)
21-
- `Error.Is` compares the underlying error instead of the message and fields, so fields no longer scope a match and two `New` calls with the same text no longer match (**breaking**)
22-
- `%+v` prints the underlying error with `%+v`, the fields, the stack trace, and then the causes of every `*Error` found through single-error wrappers, each with `%+v`
23-
- `Error.Format` honors width, precision and flags for `%s`, `%q`, `%v` and `%x`
24-
- `Error.StackTrace` returns a copy
21+
- `Error.Is` matches when the target's underlying error is in the chain of the underlying error, instead of comparing the message and fields, so fields no longer scope a match and two `New` calls with the same text no longer match (**breaking**)
22+
- `Error.Format` honors width, precision and flags for `%s`, `%q`, `%v` and `%x`, and `%+v` prints the causes with `%+v` after the stack trace
23+
- `Error.StackTrace` and `MultiError.Unwrap` return copies
2524
- `MultiError.Error` indents every message with a tab and reports `no errors` for an empty collection (**breaking**)
26-
- `MultiError.Unwrap` returns a copy of the collected errors
2725
- Methods of `Error` and `MultiError` no longer handle nil receivers (**breaking**)
2826

2927
### Removed

‎README.md‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Structured errors with fields, causes, and stack traces, plus a concurrent-safe
2626
- **Drop-in replacement** for the standard `errors` package – swap the import, keep `New`, `Is`, `As` and `AsType`.
2727
- **Fields** – key-value context added at any layer, merged along the chain.
2828
- **Causes** – previous errors attached with `WithCause`, all visible to `Is` and `As`.
29-
- **Stack traces** captured where the error is raised, printed with `%+v`, and reused when the error is wrapped.
29+
- **Stack traces** captured where the error is raised and printed with `%+v`.
3030
- **Immutable** – every `With*` method returns a new error.
3131
- **Multi error** – concurrent-safe collection of errors as a single `error`, with `Join` on top.
3232

@@ -94,7 +94,8 @@ errors.Is(err, ErrNotFound.WithField("id", 7)) // true, fields are not compared
9494
errors.Is(err, errors.New("not found")) // false, a different error with the same text
9595
```
9696

97-
Check the error before wrapping it, never after:
97+
Check the error before wrapping it, never after: `Wrap(nil)` returns a nil `*Error`, which is not `nil` once stored in
98+
an `error`.
9899

99100
```go
100101
func Process() error {
@@ -154,12 +155,10 @@ Full reference: [pkg.go.dev][link-go-dev-reference].
154155

155156
- **Standard library:** `Unwrap`, `Is`, `As`, `AsType` and `ErrUnsupported` are re-exported. `errors.Unwrap` returns
156157
`nil` for an `*Error`, since it unwraps to its underlying error and its causes; use `Is` and `As`.
157-
- **Main chain:** fields and stack traces are looked up through single-error wrappers only, never through causes or
158-
errors wrapping several errors, such as a `MultiError`.
159-
- **Stack traces:** `New`, `Newf` and `Wrap` reuse the stack trace of the first `*Error` in the main chain that has
160-
one, otherwise they capture up to 32 frames. `StackTrace` returns the program counters, so Sentry picks them up.
161-
- **Typed nil:** `Wrap(nil)` returns a nil `*Error`, which is not `nil` once stored in an `error`.
162-
- **Multi error:** use `ErrorOrNil` to return a collection as an `error`.
158+
- **Wrapping:** `Wrap`, `Newf` and `Fields` look for inner `*Error` values through single-error wrappers only, never
159+
through causes or errors wrapping several errors, such as a `MultiError`. The first stack trace found is reused,
160+
otherwise up to 32 frames are captured.
161+
- **Sentry:** `StackTrace` returns the program counters under the name Sentry looks for, so it picks them up.
163162

164163
## Credits
165164

0 commit comments

Comments
 (0)