Skip to content

Commit 8eb60cb

Browse files
committed
docs: improve WithWarnFunc documentation
Document how to collect all errors while continuing discovery, and clarify that without WithWarnFunc the first error causes failure.
1 parent 30e1f3d commit 8eb60cb

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

discover.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,25 @@ func WithInfoTimeout(d time.Duration) DiscoverOption {
130130
}
131131
}
132132

133-
// WithWarnFunc sets a callback for non-fatal warnings during discovery.
134-
// Warnings include unreadable directories and plugin metadata timeouts.
135-
// If not set, warnings are silently ignored and discovery continues.
136-
// This is useful for logging partial failures without aborting discovery.
133+
// WithWarnFunc sets a callback for non-fatal errors during discovery.
134+
// When set, discovery continues past errors (unreadable directories, plugin
135+
// metadata timeouts) by calling the callback instead of failing. Without this
136+
// option, the first error causes [Discover] to return immediately.
137137
//
138-
// Example:
138+
// To collect all errors while still completing discovery:
139+
//
140+
// var errs []error
141+
// plugins, _ := cli.Discover(
142+
// cli.WithDirs(cli.DefaultDirs("myapp")...),
143+
// cli.WithWarnFunc(func(err error) {
144+
// errs = append(errs, err)
145+
// }),
146+
// )
147+
// if len(errs) > 0 {
148+
// // Handle accumulated errors
149+
// }
150+
//
151+
// For simple logging:
139152
//
140153
// cli.Discover(
141154
// cli.WithDirs(cli.DefaultDirs("myapp")...),

0 commit comments

Comments
 (0)