Skip to content
Snippets Groups Projects
Commit 31494a7b authored by Aksel Baardsen's avatar Aksel Baardsen
Browse files

now checks for timeout using net.Error

parent 137637d4
No related branches found
No related tags found
No related merge requests found
package pkg
import (
"net"
"strconv"
"strings"
"time"
)
......@@ -29,7 +29,7 @@ func GetDiag(d* Diag) error {
// gets status of GBIF api, returns appropriate error
if err := getGbifStatus(d); err != nil{
// if it was a timeout caused by the http.client there was no returned status code of API
if strings.Contains(err.Error(), "error occurred while contacting") {
if err, ok:= err.(net.Error); ok && err.Timeout() {
d.Gbif = "The server did not give a timely response: No status code returned"
} else {
return err
......@@ -39,7 +39,7 @@ func GetDiag(d* Diag) error {
// gets status of restcountries api, returns appropriate error
if err := getRestStatus(d); err != nil {
// if it was a timeout caused by the http.client there was no returned status code of API
if strings.Contains(err.Error(), "error occurred while contacting") {
if err, ok:= err.(net.Error); ok && err.Timeout() {
d.Gbif = "The server did not give a timely response: No status code returned"
} else {
return err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment