8
8
)
9
9
10
10
type (
11
- // Handler is a function type used to process error values in Handle and
12
- // Catch. We currently have a few build-ins of the Handler: err2. Noop,
13
- // err2. Reset, etc.
11
+ // Handler is a function type used to process error values in [ Handle] and
12
+ // [ Catch] . We currently have a few build-ins of the Handler: [ Noop] ,
13
+ // [ Reset] , etc.
14
14
Handler = handler.ErrorFn
15
15
)
16
16
34
34
ErrRecoverable = errors .New ("recoverable" )
35
35
36
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
37
+ // [ 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
39
// works, e.g., in CLI apps.
40
40
Stdnull = & nullDev {}
41
41
)
66
66
// defer err2.Handle(&err, nil) // nil arg disable automatic annotation.
67
67
//
68
68
// In case of the actual error handling, the handler function should be given as
69
- // an second argument:
69
+ // a second argument:
70
70
//
71
71
// defer err2.Handle(&err, func(err error) error {
72
72
// if rmErr := os.Remove(dst); rmErr != nil {
77
77
//
78
78
// You can have unlimited amount of error handlers. They are called if error
79
79
// happens and they are called in the same order as they are given or until one
80
- // of them resets the error like Reset (notice the other predefined error
80
+ // of them resets the error like [ Reset] (notice the other predefined error
81
81
// handlers) in the next samples:
82
82
//
83
83
// defer err2.Handle(&err, err2.Reset, err2.Log) // Log not called
@@ -118,9 +118,10 @@ func Handle(err *error, a ...any) {
118
118
// the defer.
119
119
//
120
120
// The deferred Catch is very convenient, because it makes your current
121
- // goroutine panic and error-safe, one line only! You can fine tune its
122
- // behavior with functions like err2.SetErrorTrace, assert.SetDefault, and
123
- // logging settings. Start with the defaults and simplest version of Catch:
121
+ // goroutine panic and error-safe. You can fine tune its 'global' behavior with
122
+ // functions like [SetErrorTracer], [SetPanicTracer], and [SetLogTracer]. Its
123
+ // 'local' behavior depends the arguments you give it. Let's start with the
124
+ // defaults and simplest version of Catch:
124
125
//
125
126
// defer err2.Catch()
126
127
//
@@ -139,9 +140,9 @@ func Handle(err *error, a ...any) {
139
140
//
140
141
// The next one stops errors and panics, but allows you handle errors, like
141
142
// cleanups, etc. The error handler function has same signature as Handle's
142
- // error handling function, i.e., err2. Handler. By returning nil resets the
143
+ // error handling function [ Handler] . By returning nil resets the
143
144
// error, which allows e.g. prevent automatic error logs to happening.
144
- // Otherwise, the output results depends on the current Tracer and assert
145
+ // Otherwise, the output results depends on the current [ Tracer] and assert
145
146
// settings. The default trace setting prints call stacks for panics but not for
146
147
// errors:
147
148
//
0 commit comments