|
74 | 74 | // return err
|
75 | 75 | // })
|
76 | 76 | //
|
| 77 | +// You can have unlimited amount of error handlers. They are called if error |
| 78 | +// happens and they are called in the same order as they are given or until one |
| 79 | +// of them resets the error like Reset (notice other predefined error handlers) |
| 80 | +// in next sample: |
| 81 | +// |
| 82 | +// defer err2.Handle(err2.Noop, err2.Reset, err2.Log) // err2.Log not called! |
| 83 | +// |
77 | 84 | // If you need to stop general panics in handler, you can do that by giving a
|
78 | 85 | // panic handler function:
|
79 | 86 | //
|
@@ -131,16 +138,23 @@ func Handle(err *error, a ...any) {
|
131 | 138 | // error handling function, i.e., err2.Handler. By returning nil resets the
|
132 | 139 | // error, which allows e.g. prevent automatic error logs to happening.
|
133 | 140 | // Otherwise, the output results depends on the current Tracer and assert
|
134 |
| -// settings. Default setting print call stacks for panics but not for errors: |
| 141 | +// settings. The default trace setting prints call stacks for panics but not for |
| 142 | +// errors: |
135 | 143 | //
|
136 | 144 | // defer err2.Catch(func(err error) error { return err} )
|
137 | 145 | //
|
138 | 146 | // or if you you prefer to use dedicated helpers:
|
139 | 147 | //
|
140 | 148 | // defer err2.Catch(err2.Noop)
|
141 | 149 | //
|
142 |
| -// The last one calls your error handler, and you have an explicit panic |
143 |
| -// handler too, where you can e.g. continue panicking to propagate it for above |
| 150 | +// You can have unlimited amount of error handlers. They are called if error |
| 151 | +// happens and they are called in the same order as they are given or until one |
| 152 | +// of them resets the error like Reset in next sample: |
| 153 | +// |
| 154 | +// defer err2.Catch(err2.Noop, err2.Reset, err2.Log) // err2.Log not called! |
| 155 | +// |
| 156 | +// The last one calls your error handler, and you have an explicit panic handler |
| 157 | +// as well, where you can e.g. continue panicking to propagate it for above |
144 | 158 | // callers or stop it like below:
|
145 | 159 | //
|
146 | 160 | // defer err2.Catch(func(err error) error { return err }, func(p any) {})
|
|
0 commit comments