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
ea7166b8
Commit
ea7166b8
authored
Mar 19, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ref(client): use anonymous embedded error
/cc @technosophos
parent
6adaa45c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
16 deletions
+6
-16
client.go
pkg/client/client.go
+6
-16
No files found.
pkg/client/client.go
View file @
ea7166b8
...
...
@@ -118,7 +118,7 @@ func (c *Client) Delete(endpoint string, v interface{}) (*Response, error) {
func
(
c
*
Client
)
NewRequest
(
method
,
endpoint
string
,
payload
interface
{})
*
Request
{
u
,
err
:=
c
.
url
(
endpoint
)
if
err
!=
nil
{
return
&
Request
{
err
:
err
}
return
&
Request
{
err
or
:
err
}
}
body
:=
prepareBody
(
payload
)
...
...
@@ -153,7 +153,7 @@ func (c *Client) Exec(req *Request, v interface{}) (*Response, error) {
// Result checks status code and decodes a response body
func
(
c
*
Client
)
Result
(
resp
*
Response
,
v
interface
{})
(
*
Response
,
error
)
{
switch
{
case
resp
.
err
!=
nil
:
case
resp
.
err
or
!=
nil
:
return
resp
,
resp
case
resp
.
StatusCode
<
http
.
StatusOK
||
resp
.
StatusCode
>=
http
.
StatusMultipleChoices
:
return
resp
,
resp
.
HTTPError
()
...
...
@@ -164,8 +164,8 @@ func (c *Client) Result(resp *Response, v interface{}) (*Response, error) {
// Do send a request and returns a response
func
(
c
*
Client
)
Do
(
req
*
Request
)
*
Response
{
if
req
.
err
!=
nil
{
return
&
Response
{
err
:
req
}
if
req
.
err
or
!=
nil
{
return
&
Response
{
err
or
:
req
}
}
client
:=
&
http
.
Client
{
...
...
@@ -254,23 +254,13 @@ func DefaultServerURL(host string) (*url.URL, error) {
// Request wraps http.Request to include error
type
Request
struct
{
*
http
.
Request
err
error
}
// Error implements the error interface.
func
(
r
*
Request
)
Error
()
string
{
return
fmt
.
Sprint
(
"%s"
,
r
.
err
)
error
}
// Response wraps http.Response to include error
type
Response
struct
{
*
http
.
Response
err
error
}
// Error implements the error interface.
func
(
r
*
Response
)
Error
()
string
{
return
fmt
.
Sprint
(
"%s"
,
r
.
err
)
error
}
// HTTPError creates a new HTTPError from response
...
...
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