File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,23 @@ func LogTracer() io.Writer {
27
27
}
28
28
29
29
// SetErrorTracer sets a [io.Writer] for automatic error stack tracing. The err2
30
- // default is nil. Note that the current function is capable to print error
31
- // stack trace when the function has at least one deferred error handler, e.g :
30
+ // default is nil. Note that any function that has deferred [Handle] or [Catch]
31
+ // is capable to print error stack trace :
32
32
//
33
33
// func CopyFile(src, dst string) (err error) {
34
- // defer err2.Handle(&err) // <- error trace print decision is done here
34
+ // defer err2.Handle(&err) // <- makes error trace printing decision
35
+ //
36
+ // Error trace is almost the same format as Go's standard call stack but it may
37
+ // have multiple sections because every [Handle] and [Catch] prints it. If an
38
+ // error happens in a deep call stack, the error trace includes various parts.
39
+ // The principle is similar to [Zig Error Return Traces], where you see how
40
+ // error bubbles up. However, our error trace is a combination of error return
41
+ // traces and stack traces because we get all the needed information at once.
35
42
//
36
43
// Remember that you can reset these with [flag] package support. See
37
44
// documentation of err2 package's flag section.
45
+ //
46
+ // [Zig Error Return Traces]: https://ziglang.org/documentation/master/#Error-Return-Traces
38
47
func SetErrorTracer (w io.Writer ) {
39
48
tracer .Error .SetTracer (w )
40
49
}
You can’t perform that action at this time.
0 commit comments