Commit 31494a7b authored by Aksel Baardsen's avatar Aksel Baardsen
Browse files

now checks for timeout using net.Error

parent 137637d4
package pkg package pkg
import ( import (
"net"
"strconv" "strconv"
"strings"
"time" "time"
) )
...@@ -29,7 +29,7 @@ func GetDiag(d* Diag) error { ...@@ -29,7 +29,7 @@ func GetDiag(d* Diag) error {
// gets status of GBIF api, returns appropriate error // gets status of GBIF api, returns appropriate error
if err := getGbifStatus(d); err != nil{ 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 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" d.Gbif = "The server did not give a timely response: No status code returned"
} else { } else {
return err return err
...@@ -39,7 +39,7 @@ func GetDiag(d* Diag) error { ...@@ -39,7 +39,7 @@ func GetDiag(d* Diag) error {
// gets status of restcountries api, returns appropriate error // gets status of restcountries api, returns appropriate error
if err := getRestStatus(d); err != nil { 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 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" d.Gbif = "The server did not give a timely response: No status code returned"
} else { } else {
return err return err
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment