Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Aksel Baardsen
Assignment 1
Commits
31494a7b
Commit
31494a7b
authored
Oct 20, 2019
by
Aksel Baardsen
Browse files
now checks for timeout using net.Error
parent
137637d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
pkg/diag.go
View file @
31494a7b
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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment