Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
61a9296b
Commit
61a9296b
authored
Mar 29, 2016
by
Michelle Noorali
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #487 from michelleN/error-handling
ref(client): return cleaner errors
parents
cbe756cb
af01eeb6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
repository.go
cmd/helm/repository.go
+0
-1
client.go
pkg/client/client.go
+16
-0
No files found.
cmd/helm/repository.go
View file @
61a9296b
...
@@ -83,7 +83,6 @@ func addRepo(c *cli.Context) error {
...
@@ -83,7 +83,6 @@ func addRepo(c *cli.Context) error {
payload
,
_
:=
json
.
Marshal
(
repo
.
Repo
{
URL
:
repoURL
,
Name
:
name
})
payload
,
_
:=
json
.
Marshal
(
repo
.
Repo
{
URL
:
repoURL
,
Name
:
name
})
msg
:=
""
msg
:=
""
if
_
,
err
:=
NewClient
(
c
)
.
Post
(
chartRepoPath
,
payload
,
&
msg
);
err
!=
nil
{
if
_
,
err
:=
NewClient
(
c
)
.
Post
(
chartRepoPath
,
payload
,
&
msg
);
err
!=
nil
{
//TODO: Return more specific errors to the user
return
err
return
err
}
}
format
.
Info
(
name
+
" has been added to your chart repositories!"
)
format
.
Info
(
name
+
" has been added to your chart repositories!"
)
...
...
pkg/client/client.go
View file @
61a9296b
...
@@ -27,6 +27,7 @@ import (
...
@@ -27,6 +27,7 @@ import (
"strings"
"strings"
"time"
"time"
"github.com/kubernetes/helm/pkg/httputil"
"github.com/kubernetes/helm/pkg/version"
"github.com/kubernetes/helm/pkg/version"
)
)
...
@@ -221,8 +222,20 @@ func (r *Response) Success() bool {
...
@@ -221,8 +222,20 @@ func (r *Response) Success() bool {
// HTTPError creates a new HTTPError from response
// HTTPError creates a new HTTPError from response
func
(
r
*
Response
)
HTTPError
()
error
{
func
(
r
*
Response
)
HTTPError
()
error
{
contentType
:=
r
.
Header
.
Get
(
"Content-Type"
)
defer
r
.
Body
.
Close
()
defer
r
.
Body
.
Close
()
body
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
body
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
if
contentType
==
"application/json"
{
httpErr
:=
httputil
.
Error
{}
json
.
Unmarshal
(
body
,
&
httpErr
)
return
&
HTTPError
{
StatusCode
:
r
.
StatusCode
,
Message
:
httpErr
.
Msg
,
URL
:
r
.
Request
.
URL
,
}
}
else
{
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -231,6 +244,9 @@ func (r *Response) HTTPError() error {
...
@@ -231,6 +244,9 @@ func (r *Response) HTTPError() error {
Message
:
string
(
body
),
Message
:
string
(
body
),
URL
:
r
.
Request
.
URL
,
URL
:
r
.
Request
.
URL
,
}
}
}
return
nil
}
}
// HTTPError is an error caused by an unexpected HTTP status code.
// HTTPError is an error caused by an unexpected HTTP status code.
...
...
Write
Preview
Markdown
is supported
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