Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kubo_final
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Anastasiia Chirikova
kubo_final
Commits
6350cff7
Commit
6350cff7
authored
Mar 21, 2015
by
Henry
Browse files
Options
Downloads
Patches
Plain Diff
pollEndpoint: improve error output
parent
039526b9
No related branches found
No related tags found
1 merge request
!1
New
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
thirdparty/pollEndpoint/main.go
+6
-5
6 additions, 5 deletions
thirdparty/pollEndpoint/main.go
with
6 additions
and
5 deletions
thirdparty/pollEndpoint/main.go
+
6
−
5
View file @
6350cff7
...
...
@@ -4,6 +4,7 @@ package main
import
(
"flag"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
...
...
@@ -79,15 +80,15 @@ func main() {
func
checkOK
(
resp
*
http
.
Response
,
err
error
)
error
{
if
err
==
nil
{
// request worked
resp
.
Body
.
Close
()
defer
resp
.
Body
.
Close
()
if
resp
.
StatusCode
==
http
.
StatusOK
{
return
nil
}
return
fmt
.
Errorf
(
"Response not OK. %d %s"
,
resp
.
StatusCode
,
resp
.
Status
)
}
else
if
urlErr
,
ok
:=
err
.
(
*
url
.
Error
);
ok
{
// expected error from http.Get()
if
urlErr
.
Op
!=
"Get"
||
urlErr
.
URL
!=
*
endpoint
{
return
fmt
.
Errorf
(
"wrong url or endpoint error from http.Get() %#v"
,
urlErr
)
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"pollEndpoint: ioutil.ReadAll() Error: %s"
,
err
)
}
return
fmt
.
Errorf
(
"Response not OK. %d %s %q"
,
resp
.
StatusCode
,
resp
.
Status
,
string
(
body
))
}
return
err
}
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