Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme and docs #53

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ If you don't want to bother with adding any additional metadata, you can just us
You can also add context with slog attributes with `Wraps`

```go
return errors.Wraps(err, "failure", "id", 5, "key", "value)
return errors.Wraps(err, "failure message", slog.Int("id", 5), slog.String("key", "value))
// or untyped just as in slog
return errors.Wraps(err, "failure message", "id", 5, "key", "value)
```

## Using with standard library errors
Expand Down
2 changes: 1 addition & 1 deletion errwrap/go_123.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// UnwrapGroups will unwrap errors visiting each one.
// Any ErrorGroup is expanded and traversed
// An error that defines Unwrap() []error is expanded and traversed
// This is a depth-first traversal, doing the unwrap first and the expansion second.
// This can be used for functionality similar to errors.As but it also expands error groups.
func UnwrapGroups(err error) iter.Seq[error] {
Expand Down
2 changes: 1 addition & 1 deletion errwrap/wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func writeString(w io.Writer, s string) {
// UnwrapGroups is now preferred for those using Go version >= 1.23.
// Note that WalkDeep uses the opposite convention for boolean return values compared to golang iterators.
// WalkDeep does a depth-first traversal of all errors.
// Any ErrorGroup is traversed (after first unwrapping deeply).
// An error that defines Unwrap() []error is expanded and traversed
// The visitor function can return true to end the traversal early
// If iteration is ended early, WalkDeep will return true, otherwise false.
func WalkDeep(err error, visitor func(err error) bool) bool {
Expand Down
Loading