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) { ...@@ -21,6 +21,6 @@ func Dhandler(w http.ResponseWriter, r *http.Request) {
log.Fatal(err) log.Fatal(err)
} }
} else { } else {
http.Error(w, err.Error(), http.StatusBadGateway) pkg.HttpError(w, err)
} }
} }
...@@ -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 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" 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 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" d.Gbif = "The server did not give a timely response: No status code returned"
} else { } else {
return err return err
......
...@@ -70,7 +70,7 @@ func getBody(url string, m mashup) error { ...@@ -70,7 +70,7 @@ func getBody(url string, m mashup) error {
func HttpError(w http.ResponseWriter, err error) { func HttpError(w http.ResponseWriter, err error) {
// if timeout happened // 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) http.Error(w, "Request to API timed out", http.StatusGatewayTimeout)
return // return if error is already displayed 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