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

fixed overwriting errormessage

parent 7322b1bc
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,6 @@ func Dhandler(w http.ResponseWriter, r *http.Request) {
log.Fatal(err)
}
} else {
http.Error(w, err.Error(), http.StatusBadGateway)
pkg.HttpError(w, err)
}
}
......@@ -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 err, ok:= err.(net.Error); ok && err.Timeout() {
if errT, ok := err.(net.Error); ok && errT.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 err, ok:= err.(net.Error); ok && err.Timeout() {
if errT, ok := err.(net.Error); ok && errT.Timeout() {
d.Gbif = "The server did not give a timely response: No status code returned"
} else {
return err
......
......@@ -70,7 +70,7 @@ func getBody(url string, m mashup) error {
func HttpError(w http.ResponseWriter, err error) {
// if timeout happened
if err, ok:= err.(net.Error); ok && err.Timeout() {
if errT, ok := err.(net.Error); ok && errT.Timeout() {
http.Error(w, "Request to API timed out", http.StatusGatewayTimeout)
return // return if error is already displayed
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment