Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add URL attribute to Error struct

  • Loading branch information...
commit 5f33c5e5af54058634c247c22d6f697a9e397b7a 1 parent 575442c
@bgentry authored
Showing with 15 additions and 3 deletions.
  1. +5 −3 heroku.go
  2. +10 −0 heroku_test.go
View
8 heroku.go
@@ -22,7 +22,7 @@ import (
)
const (
- Version = "0.5.1"
+ Version = "0.5.2"
DefaultAPIURL = "https://api.heroku.com"
DefaultUserAgent = "heroku-go/" + Version + " (" + runtime.GOOS + "; " + runtime.GOARCH + ")"
)
@@ -216,12 +216,14 @@ func (c *Client) DoReq(req *http.Request, v interface{}) error {
// An Error represents a Heroku API error.
type Error struct {
error
- Id string
+ Id string
+ URL string
}
type errorResp struct {
Message string
Id string
+ URL string `json:"url"`
}
func checkResp(res *http.Response) error {
@@ -231,7 +233,7 @@ func checkResp(res *http.Response) error {
if err != nil {
return errors.New("Unexpected error: " + res.Status)
}
- return Error{error: errors.New(e.Message), Id: e.Id}
+ return Error{error: errors.New(e.Message), Id: e.Id, URL: e.URL}
}
if msg := res.Header.Get("X-Heroku-Warning"); msg != "" {
fmt.Fprintln(os.Stderr, strings.TrimSpace(msg))
View
10 heroku_test.go
@@ -141,6 +141,7 @@ var respTests = []respTest{
Error{
error: errors.New("You do not have access to the app myapp."),
Id: "forbidden",
+ URL: "",
},
},
{
@@ -148,6 +149,15 @@ var respTests = []respTest{
Error{
error: errors.New("Long error message."),
Id: "unauthorized",
+ URL: "",
+ },
+ },
+ {
+ newTestResponse(422, `{"id": "invalid_params", "message": "Cannot scale to more than 5 PX size dynos per process type.", "url": "https://bit.ly/1gK1TvU"}`),
+ Error{
+ error: errors.New("Cannot scale to more than 5 PX size dynos per process type."),
+ Id: "invalid_params",
+ URL: "https://bit.ly/1gK1TvU",
},
},
{
Please sign in to comment.
Something went wrong with that request. Please try again.