-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapwithfuncparams_test.go
More file actions
42 lines (32 loc) · 954 Bytes
/
wrapwithfuncparams_test.go
File metadata and controls
42 lines (32 loc) · 954 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
package errs
import (
"context"
"fmt"
)
type strct struct {
A int
}
func funcA(ctx context.Context, i int, s string, strct *strct) (err error) {
defer WrapWith4FuncParams(&err, ctx, i, s, strct)
return funcB(s, "X\nX")
}
func funcB(s ...string) (err error) {
defer WrapWithFuncParams(&err, s)
return funcC()
}
func funcC() (err error) {
defer WrapWithFuncParams(&err)
return New("error in funcC")
}
func ExampleWrapWithFuncParams() {
err := funcA(context.Background(), 666, "Hello World!", &strct{A: -1})
fmt.Println(err)
// Output:
// error in funcC
// github.com/domonda/go-errs.funcC()
// github.com/domonda/go-errs/wrapwithfuncparams_test.go:27
// github.com/domonda/go-errs.funcB([`Hello World!`,`X\nX`])
// github.com/domonda/go-errs/wrapwithfuncparams_test.go:21
// github.com/domonda/go-errs.funcA(Context{}, 666, `Hello World!`, strct{A:-1})
// github.com/domonda/go-errs/wrapwithfuncparams_test.go:15
}