Skip to content

Commit

Permalink
ExampleLogTransport: More consistent errors
Browse files Browse the repository at this point in the history
  • Loading branch information
earthboundkid committed Mar 30, 2023
1 parent 7fa23e7 commit 829fc3d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions transport_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func ExampleLogTransport() {
Transport(trans).
ToString(&s).
Fetch(context.Background()); err != nil {
panic(err)
fmt.Println("Error!", err)
}
// Works for bad responses too
baseTrans = requests.RoundTripFunc(func(req *http.Request) (*http.Response, error) {
Expand All @@ -121,10 +121,10 @@ func ExampleLogTransport() {
Transport(trans).
ToString(&s).
Fetch(context.Background()); err != nil {
fmt.Println(err)
fmt.Println("Error!", err)
}
// Output:
// method="GET" url="http://example.com/" err=<nil> status="200 OK" duration=0s
// method="GET" url="http://example.com/" err=can't connect status="" duration=0s
// ErrTransport: Get "http://example.com/": can't connect
// Error! ErrTransport: Get "http://example.com/": can't connect
}

0 comments on commit 829fc3d

Please sign in to comment.