Merge lp:~allenap/gwacl/extend-azure-error into lp:gwacl

Proposed by Gavin Panella on 2013-07-11
Status: Merged
Approved by: Gavin Panella on 2013-07-11
Approved revision: 177
Merged at revision: 177
Proposed branch: lp:~allenap/gwacl/extend-azure-error
Merge into: lp:gwacl
Diff against target: 65 lines (+29/-14)
2 files modified
httperror.go (+7/-3)
httperror_test.go (+22/-11)
To merge this branch: bzr merge lp:~allenap/gwacl/extend-azure-error
Reviewer Review Type Date Requested Status
Raphaël Badin (community) 2013-07-11 Approve on 2013-07-11
Review via email: mp+174165@code.launchpad.net

Commit message

Ensure that extendError() treats AzureError specially too.

To post a comment you must log in.
Raphaël Badin (rvb) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'httperror.go'
--- httperror.go 2013-07-09 20:01:18 +0000
+++ httperror.go 2013-07-11 10:55:34 +0000
@@ -103,9 +103,13 @@
103func extendError(err error, message string) error {103func extendError(err error, message string) error {
104 switch err := err.(type) {104 switch err := err.(type) {
105 case *ServerError:105 case *ServerError:
106 returnedErr := *err106 extendedError := *err
107 returnedErr.error = fmt.Errorf(message+"%v", err.error)107 extendedError.error = fmt.Errorf(message+"%v", err.error)
108 return &returnedErr108 return &extendedError
109 case *AzureError:
110 extendedError := *err
111 extendedError.error = fmt.Errorf(message+"%v", err.error)
112 return &extendedError
109 default:113 default:
110 return fmt.Errorf(message+"%v", err)114 return fmt.Errorf(message+"%v", err)
111 }115 }
112116
=== modified file 'httperror_test.go'
--- httperror_test.go 2013-07-09 20:01:18 +0000
+++ httperror_test.go 2013-07-11 10:55:34 +0000
@@ -104,18 +104,29 @@
104}104}
105105
106func (suite *httpErrorSuite) TestExtendErrorExtendsServerError(c *C) {106func (suite *httpErrorSuite) TestExtendErrorExtendsServerError(c *C) {
107 description := "could not talk to server"107 err := &ServerError{
108 status := http.StatusGatewayTimeout108 error: errors.New("could not talk to server"),
109 httpErr := newHTTPError(status, []byte{}, description)109 HTTPStatus: HTTPStatus(http.StatusGatewayTimeout),
110 }
111 additionalErrorMsg := "additional message: "
112 newError := extendError(err, additionalErrorMsg)
113 newServerError, ok := newError.(*ServerError)
114 c.Assert(ok, Equals, true)
115 c.Check(newError.Error(), Equals, additionalErrorMsg+err.Error())
116 c.Check(newServerError.HTTPStatus, Equals, err.HTTPStatus)
117}
110118
111 httpServerErr, ok := httpErr.(*ServerError)119func (suite *httpErrorSuite) TestExtendErrorExtendsAzureError(c *C) {
112 c.Assert(ok, Equals, true)120 err := &AzureError{
113 additionalErrorMsg := "additional message"121 error: errors.New("could not talk to server"),
114 newError := extendError(httpErr, additionalErrorMsg)122 HTTPStatus: HTTPStatus(http.StatusGatewayTimeout),
115 newServerError, ok := httpErr.(*ServerError)123 }
116 c.Assert(ok, Equals, true)124 additionalErrorMsg := "additional message: "
117 c.Check(newError.Error(), Equals, fmt.Sprintf("%s%s", additionalErrorMsg, httpErr.Error()))125 newError := extendError(err, additionalErrorMsg)
118 c.Check(httpServerErr.HTTPStatus, Equals, newServerError.HTTPStatus)126 newAzureError, ok := newError.(*AzureError)
127 c.Assert(ok, Equals, true)
128 c.Check(newError.Error(), Equals, additionalErrorMsg+err.Error())
129 c.Check(newAzureError.HTTPStatus, Equals, err.HTTPStatus)
119}130}
120131
121func (suite *httpErrorSuite) TestIsNotFound(c *C) {132func (suite *httpErrorSuite) TestIsNotFound(c *C) {

Subscribers

People subscribed via source and target branches

to all changes: