-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_fixtures2_test.go
More file actions
48 lines (37 loc) · 861 Bytes
/
stack_fixtures2_test.go
File metadata and controls
48 lines (37 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package wrapperr_test
import (
"github.com/dc0d/wrapperr"
)
func fix1() error {
return steps{
func() error { return nil },
func() error { return nil },
func() error { return wrapperr.WithStack(errRootCause, "annotated root cause") },
func() error { return nil },
}.run()
}
func fix2() error {
return wrapperr.WithStack(errRootCause, "annotated root cause")
}
func fix3() error {
if err := fix2(); err != nil {
return wrapperr.WithStackf(err, "sample %v", "annotation")
}
return nil
}
func fix4() error {
if err := fix3(); err != nil {
return wrapperr.WithStack(err, "second sample", "annotation")
}
return nil
}
type steps []step
func (steps steps) run() error {
for _, fn := range steps {
if err := fn(); err != nil {
return wrapperr.WithStackf(err, "sample %v", "annotation")
}
}
return nil
}
type step func() error