handle timeout errors
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
d611a6aed5
commit
a1a3daa799
11
http.go
11
http.go
@ -109,8 +109,19 @@ func (h *httpClient) call(ctx context.Context, addr string, req client.Request,
|
||||
// make the request
|
||||
hrsp, err := h.httpcli.Do(hreq.WithContext(ctx))
|
||||
if err != nil {
|
||||
switch err := err.(type) {
|
||||
case net.Error:
|
||||
if err.Timeout() {
|
||||
return errors.Timeout("go.micro.client", err.Error())
|
||||
}
|
||||
case *url.Error:
|
||||
if err, ok := err.Err.(net.Error); ok && err.Timeout() {
|
||||
return errors.Timeout("go.micro.client", err.Error())
|
||||
}
|
||||
}
|
||||
return errors.InternalServerError("go.micro.client", err.Error())
|
||||
}
|
||||
|
||||
defer hrsp.Body.Close()
|
||||
|
||||
return parseRsp(ctx, hrsp, cf, rsp, opts)
|
||||
|
Loading…
Reference in New Issue
Block a user