MCPcopy Create free account
hub / github.com/bracesdev/errtrace / Example_http

Function Example_http

benchext/pkgerrors_example_http_test.go:14–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12)
13
14func Example_http() {
15 tp := &http.Transport{Dial: rateLimitDialer}
16 client := &http.Client{Transport: tp}
17 ps := &PackageStore{
18 client: client,
19 }
20
21 _, err := ps.Get()
22
23 // Unwrap the HTTP-wrapped error, so we can print a proper stacktrace.
24 var stErr interface {
25 error
26 StackTrace() errors.StackTrace
27 }
28 if errors.As(err, &stErr) {
29 err = stErr
30 }
31
32 fmt.Printf("Error fetching packages: %s\n", cleanGoRoot(tracetest.MustClean(fmt.Sprintf("%+v", err))))
33 // Output:
34 // Error fetching packages: connect rate limited
35 // braces.dev/errtrace/benchext.rateLimitDialer
36 // /path/to/errtrace/benchext/pkgerrors_example_http_test.go:1
37 // net/http.(*Transport).dial
38 // /goroot/src/net/http/transport.go:0
39 // net/http.(*Transport).dialConn
40 // /goroot/src/net/http/transport.go:0
41 // net/http.(*Transport).dialConnFor
42 // /goroot/src/net/http/transport.go:0
43 // runtime.goexit
44 // /goroot/src/runtime/asm_amd64.s:0
45}
46
47type PackageStore struct {
48 client *http.Client

Callers

nothing calls this directly

Calls 3

GetMethod · 0.95
MustCleanFunction · 0.92
cleanGoRootFunction · 0.85

Tested by

no test coverage detected