()
| 173 | } |
| 174 | |
| 175 | func Example_stackTrace() { |
| 176 | type stackTracer interface { |
| 177 | StackTrace() errors.StackTrace |
| 178 | } |
| 179 | |
| 180 | err, ok := errors.Cause(fn()).(stackTracer) |
| 181 | if !ok { |
| 182 | panic("oops, err does not implement stackTracer") |
| 183 | } |
| 184 | |
| 185 | st := err.StackTrace() |
| 186 | fmt.Printf("%+v", st[0:2]) // top two frames |
| 187 | |
| 188 | // Example output: |
| 189 | // github.com/pkg/errors_test.fn |
| 190 | // /home/dfc/src/github.com/pkg/errors/example_test.go:47 |
| 191 | // github.com/pkg/errors_test.Example_stackTrace |
| 192 | // /home/dfc/src/github.com/pkg/errors/example_test.go:127 |
| 193 | } |
| 194 | |
| 195 | func ExampleCause_printf() { |
| 196 | err := errors.Wrap(func() error { |
nothing calls this directly
no test coverage detected
searching dependent graphs…