From 78f5e4373b0810f0cbf503e4a5be848eeb5642ef Mon Sep 17 00:00:00 2001 From: Nick Mills-Barrett Date: Tue, 14 May 2024 12:43:15 +0100 Subject: [PATCH] Pass error to `Client.ResponseHook` --- client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index 686c0e19..cc133f95 100644 --- a/client.go +++ b/client.go @@ -65,7 +65,7 @@ type Client struct { Log zerolog.Logger RequestHook func(req *http.Request) - ResponseHook func(req *http.Request, resp *http.Response, duration time.Duration) + ResponseHook func(req *http.Request, resp *http.Response, err error, duration time.Duration) SyncPresence event.Presence @@ -291,10 +291,10 @@ func (cli *Client) LogRequestDone(req *http.Request, resp *http.Response, err er Str("method", req.Method). Str("url", req.URL.String()). Dur("duration", duration) + if cli.ResponseHook != nil { + cli.ResponseHook(req, resp, err, duration) + } if resp != nil { - if cli.ResponseHook != nil { - cli.ResponseHook(req, resp, duration) - } mime := resp.Header.Get("Content-Type") length := resp.ContentLength if length == -1 && contentLength > 0 {