Skip to content

Commit

Permalink
still print debug info when err happens
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Oct 27, 2021
1 parent 1e6ea56 commit 31fdd27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,11 @@ func (r *Resp) Dump() string {
l := dump.Len()
if l > 0 {
dump.WriteString("=================================")
l = dump.Len()
}

r.dumpResponse(dump)
if r.resp != nil {
r.dumpResponse(dump)
}

return dump.String()
}
11 changes: 7 additions & 4 deletions req.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ func (r *Req) Do(method, rawurl string, vs ...interface{}) (resp *Resp, err erro
}
resp = &Resp{req: req, r: r}

// output detail if Debug is enabled
if Debug {
defer func(resp *Resp) {
fmt.Println(resp.Dump())
}(resp)
}

var queryParam param
var formParam param
var uploads []FileUpload
Expand Down Expand Up @@ -340,10 +347,6 @@ func (r *Req) Do(method, rawurl string, vs ...interface{}) (resp *Resp, err erro
response.Body = body
}

// output detail if Debug is enabled
if Debug {
fmt.Println(resp.Dump())
}
return
}

Expand Down

0 comments on commit 31fdd27

Please sign in to comment.