MCPcopy Index your code
hub / github.com/bracesdev/errtrace / Example_tree

Function Example_tree

example_tree_test.go:27–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25}
26
27func Example_tree() {
28 errs := errtrace.Wrap(errors.Join(
29 normalErr(1),
30 wrapNormalErr(2),
31 nestedErrorList(3),
32 ))
33 got := errtrace.FormatString(errs)
34
35 // make trace agnostic to environment-specific location
36 // and less sensitive to line number changes.
37 fmt.Println(trimTrailingSpaces(tracetest.MustClean(got)))
38
39 // Output:
40 // +- std err 1
41 // |
42 // +- std err 2
43 // |
44 // | braces.dev/errtrace_test.wrapNormalErr
45 // | /path/to/errtrace/example_tree_test.go:1
46 // |
47 // | +- std err 3
48 // | |
49 // | +- std err 4
50 // | |
51 // | | braces.dev/errtrace_test.wrapNormalErr
52 // | | /path/to/errtrace/example_tree_test.go:1
53 // | |
54 // +- std err 3
55 // | std err 4
56 // |
57 // std err 1
58 // std err 2
59 // std err 3
60 // std err 4
61 //
62 // braces.dev/errtrace_test.Example_tree
63 // /path/to/errtrace/example_tree_test.go:2
64}
65
66func trimTrailingSpaces(s string) string {
67 lines := strings.Split(s, "\n")

Callers

nothing calls this directly

Calls 7

WrapFunction · 0.92
FormatStringFunction · 0.92
MustCleanFunction · 0.92
normalErrFunction · 0.85
wrapNormalErrFunction · 0.85
nestedErrorListFunction · 0.85
trimTrailingSpacesFunction · 0.85

Tested by

no test coverage detected