|
33 | 33 | ErrNotRecoverable = errors.New("cannot recover")
|
34 | 34 | ErrRecoverable = errors.New("recoverable")
|
35 | 35 |
|
36 |
| - // Stdnull is helper variable for io.Writer need e.g. err2.SetLogTracer in |
37 |
| - // cases you don't want to use automatic log writer, i.e. LogTracer == nil. |
38 |
| - // It's usually used to change how the Catch works, e.g., in CLI apps. |
| 36 | + // Stdnull implements io.Writer that writes nothing, e.g., |
| 37 | + // err2.SetLogTracer in cases you don't want to use automatic log writer, |
| 38 | + // i.e., LogTracer == /dev/null. It can be used to change how the Catch |
| 39 | + // works, e.g., in CLI apps. |
39 | 40 | Stdnull = &nullDev{}
|
40 | 41 | )
|
41 | 42 |
|
@@ -79,11 +80,12 @@ var (
|
79 | 80 | // of them resets the error like Reset (notice other predefined error handlers)
|
80 | 81 | // in next sample:
|
81 | 82 | //
|
| 83 | +// defer err2.Handle(&err, err2.Reset, err2.Log) // Log not called |
82 | 84 | // defer err2.Handle(&err, err2.Noop, err2.Log) // handlers > 1: err annotated
|
83 | 85 | // defer err2.Handle(&err, nil, err2.Log) // nil disables auto-annotation
|
84 | 86 | //
|
85 | 87 | // If you need to stop general panics in handler, you can do that by giving a
|
86 |
| -// panic handler function: |
| 88 | +// panic handler function. See the second handler below: |
87 | 89 | //
|
88 | 90 | // defer err2.Handle(&err,
|
89 | 91 | // err2.Err( func(error) { os.Remove(dst) }), // err2.Err() keeps it short
|
@@ -130,7 +132,7 @@ func Handle(err *error, a ...any) {
|
130 | 132 | // error message about the error source (from where the error was thrown) to the
|
131 | 133 | // currently set log. Note, when log stream isn't set, the standard log is used.
|
132 | 134 | // It can be bound to, e.g., glog. And if you want to suppress automatic logging
|
133 |
| -// use the following setup: |
| 135 | +// entirely use the following setup: |
134 | 136 | //
|
135 | 137 | // err2.SetLogTracer(err2.Stdnull)
|
136 | 138 | //
|
|
0 commit comments