Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Assignment 1
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Aksel Baardsen
Assignment 1
Commits
d5370b5b
Commit
d5370b5b
authored
Oct 20, 2019
by
Aksel Baardsen
Browse files
Options
Downloads
Patches
Plain Diff
fixed overwriting errormessage
parent
7322b1bc
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
handler/diag.go
+1
-1
1 addition, 1 deletion
handler/diag.go
pkg/diag.go
+2
-2
2 additions, 2 deletions
pkg/diag.go
pkg/funcs.go
+1
-1
1 addition, 1 deletion
pkg/funcs.go
with
4 additions
and
4 deletions
handler/diag.go
+
1
−
1
View file @
d5370b5b
...
@@ -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
{
h
ttp
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadGateway
)
pkg
.
H
ttpError
(
w
,
err
)
}
}
}
}
This diff is collapsed.
Click to expand it.
pkg/diag.go
+
2
−
2
View file @
d5370b5b
...
@@ -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
err
T
,
ok
:=
err
.
(
net
.
Error
);
ok
&&
err
T
.
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
err
T
,
ok
:=
err
.
(
net
.
Error
);
ok
&&
err
T
.
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
...
...
This diff is collapsed.
Click to expand it.
pkg/funcs.go
+
1
−
1
View file @
d5370b5b
...
@@ -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
err
T
,
ok
:=
err
.
(
net
.
Error
);
ok
&&
err
T
.
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
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment