Skip to content

Commit

Permalink
aws/awserr: Allow errors to stack
Browse files Browse the repository at this point in the history
Allow returned errors to be chained in a stack so that nested errors are
not ignored. This change updates the SDK so that the chain of errors
which occurred are all included. Instead of just the first error.
  • Loading branch information
jasdel committed Feb 8, 2016
1 parent 368825e commit 1dc53c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 0 additions & 3 deletions aws/awserr/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ type BatchError interface {
// If origErr satisfies the Error interface it will not be wrapped within a new
// Error object and will instead be returned.
func New(code, message string, origErr error) Error {
if e, ok := origErr.(Error); ok && e != nil {
return e
}
return newBaseError(code, message, origErr)
}

Expand Down
10 changes: 6 additions & 4 deletions service/s3/s3manager/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,9 @@ func TestUploadOrderReadFail2(t *testing.T) {
Body: &failreader{times: 2},
})

assert.Equal(t, "ReadRequestBody", err.(awserr.Error).Code())
assert.EqualError(t, err.(awserr.Error).OrigErr(), "random failure")
assert.Equal(t, "MultipartUpload", err.(awserr.Error).Code())
assert.Equal(t, "ReadRequestBody", err.(awserr.Error).OrigErr().(awserr.Error).Code())
assert.Contains(t, err.(awserr.Error).OrigErr().Error(), "random failure")
assert.Equal(t, []string{"CreateMultipartUpload", "AbortMultipartUpload"}, *ops)
}

Expand Down Expand Up @@ -441,8 +442,9 @@ func TestUploadOrderMultiBufferedReaderExceedTotalParts(t *testing.T) {
assert.Equal(t, []string{"CreateMultipartUpload", "AbortMultipartUpload"}, *ops)

aerr := err.(awserr.Error)
assert.Equal(t, "TotalPartsExceeded", aerr.Code())
assert.Contains(t, aerr.Message(), "configured MaxUploadParts (2)")
assert.Equal(t, "MultipartUpload", aerr.Code())
assert.Equal(t, "TotalPartsExceeded", aerr.OrigErr().(awserr.Error).Code())
assert.Contains(t, aerr.Error(), "configured MaxUploadParts (2)")
}

func TestUploadOrderSingleBufferedReader(t *testing.T) {
Expand Down

0 comments on commit 1dc53c8

Please sign in to comment.