Skip to content

Commit a1e64a4

Browse files
committed
godoc typos & better example with multi-error
1 parent 3398b49 commit a1e64a4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

err2.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,18 @@ var (
6363
// an second argument:
6464
//
6565
// defer err2.Handle(&err, func(err error) error {
66-
// os.Remove(dst)
66+
// if rmErr := os.Remove(dst); rmErr != nil {
67+
// return fmt.Errorf("%w: cleanup error: %w", err, rmErr)
68+
// }
6769
// return err
6870
// })
6971
//
7072
// If you need to stop general panics in handler, you can do that by giving a
7173
// panic handler function:
7274
//
7375
// defer err2.Handle(&err,
74-
// err2.Err( func(error) { os.Remove(dst) }), // err2.Err keeps it short
75-
// func(p any) {} // panic handler, it's stops panics, you can re-throw
76+
// err2.Err( func(error) { os.Remove(dst) }), // err2.Err() keeps it short
77+
// func(p any) {} // <- handler stops panics, re-throw or not
7678
// )
7779
func Handle(err *error, a ...any) {
7880
// This and others are similar but we need to call `recover` here because

0 commit comments

Comments
 (0)