Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aws/defaults/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func handleSendError(r *aws.Request, err error) {
ctx := r.Context()
select {
case <-ctx.Done():
r.Error = awserr.New(aws.CanceledErrorCode,
r.Error = awserr.New(aws.ErrCodeRequestCanceled,
"request context canceled", ctx.Err())
r.Retryable = aws.Bool(false)
default:
Expand Down Expand Up @@ -207,7 +207,7 @@ var AfterRetryHandler = aws.NamedHandler{Name: "core.AfterRetryHandler", Fn: fun
r.RetryDelay = r.RetryRules(r)

if err := sdk.SleepWithContext(r.Context(), r.RetryDelay); err != nil {
r.Error = awserr.New(aws.CanceledErrorCode,
r.Error = awserr.New(aws.ErrCodeRequestCanceled,
"request context canceled", err)
r.Retryable = aws.Bool(false)
return
Expand Down
4 changes: 2 additions & 2 deletions aws/defaults/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestAfterRetryWithContextCanceled(t *testing.T) {

aerr := req.Error.(awserr.Error)

if e, a := aws.CanceledErrorCode, aerr.Code(); e != a {
if e, a := aws.ErrCodeRequestCanceled, aerr.Code(); e != a {
t.Errorf("expect %q, error code got %q", e, a)
}
}
Expand Down Expand Up @@ -199,7 +199,7 @@ func TestSendWithContextCanceled(t *testing.T) {

aerr := req.Error.(awserr.Error)

if e, a := aws.CanceledErrorCode, aerr.Code(); e != a {
if e, a := aws.ErrCodeRequestCanceled, aerr.Code(); e != a {
t.Errorf("expect %q, error code got %q", e, a)
}
}
Expand Down
2 changes: 1 addition & 1 deletion aws/ec2metadata/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func New(config aws.Config) *EC2Metadata {
Name: defaults.SendHandler.Name,
Fn: func(r *aws.Request) {
r.Error = awserr.New(
aws.CanceledErrorCode,
aws.ErrCodeRequestCanceled,
"EC2 IMDS access disabled via "+disableServiceEnvVar+" env var",
nil)
},
Expand Down
2 changes: 1 addition & 1 deletion aws/ec2metadata/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestClientDisableIMDS(t *testing.T) {
}

aerr := err.(awserr.Error)
if e, a := aws.CanceledErrorCode, aerr.Code(); e != a {
if e, a := aws.ErrCodeRequestCanceled, aerr.Code(); e != a {
t.Errorf("expect %v error code, got %v", e, a)
}
if e, a := "AWS_EC2_METADATA_DISABLED", aerr.Message(); !strings.Contains(a, e) {
Expand Down
6 changes: 3 additions & 3 deletions aws/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const (
// during body reads.
ErrCodeResponseTimeout = "ResponseTimeout"

// CanceledErrorCode is the error code that will be returned by an
// ErrCodeRequestCanceled is the error code that will be returned by an
// API request that was canceled. Requests given a Context may
// return this error when canceled.
CanceledErrorCode = "RequestCanceled"
ErrCodeRequestCanceled = "RequestCanceled"
)

// A Request is the service request to be made.
Expand Down Expand Up @@ -565,7 +565,7 @@ func shouldRetryCancel(r *Request) bool {
timeoutErr := false
errStr := r.Error.Error()
if ok {
if awsErr.Code() == CanceledErrorCode {
if awsErr.Code() == ErrCodeRequestCanceled {
return false
}
err := awsErr.OrigErr()
Expand Down
2 changes: 1 addition & 1 deletion aws/waiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (w Waiter) WaitWithContext(ctx Context) error {

// Delay to wait before inspecting the resource again
if err := sdk.SleepWithContext(ctx, w.Delay(attempt)); err != nil {
return awserr.New(CanceledErrorCode, "waiter context canceled", err)
return awserr.New(ErrCodeRequestCanceled, "waiter context canceled", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion aws/waiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ func TestWaiter_WithContextCanceled(t *testing.T) {
t.Fatalf("expect waiter to be canceled.")
}
aerr := err.(awserr.Error)
if e, a := aws.CanceledErrorCode, aerr.Code(); e != a {
if e, a := aws.ErrCodeRequestCanceled, aerr.Code(); e != a {
t.Errorf("expect %q error code, got %q", e, a)
}
if e, a := 2, reqCount; e != a {
Expand Down
4 changes: 2 additions & 2 deletions example/aws/request/withContext/withContext.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ func main() {
req.SetContext(ctx)

if _, err := req.Send(); err != nil {
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == request.CanceledErrorCode {
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == request.ErrCodeRequestCanceled {
// If the SDK can determine the request or retry delay was canceled
// by a context the CanceledErrorCode error code will be returned.
// by a context the ErrCodeRequestCanceled error code will be returned.
fmt.Fprintf(os.Stderr, "upload canceled due to timeout, %v\n", err)
} else {
fmt.Fprintf(os.Stderr, "failed to upload object, %v\n", err)
Expand Down
2 changes: 1 addition & 1 deletion service/s3/s3crypto/decryption_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func TestGetObjectWithContext(t *testing.T) {
t.Fatalf("expected error, did not get one")
}
aerr := err.(awserr.Error)
if e, a := aws.CanceledErrorCode, aerr.Code(); e != a {
if e, a := aws.ErrCodeRequestCanceled, aerr.Code(); e != a {
t.Errorf("expected error code %q, got %q", e, a)
}
if e, a := "canceled", aerr.Message(); !strings.Contains(a, e) {
Expand Down
2 changes: 1 addition & 1 deletion service/s3/s3crypto/encryption_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestPutObjectWithContext(t *testing.T) {
t.Fatalf("expected error, did not get one")
}
aerr := err.(awserr.Error)
if e, a := aws.CanceledErrorCode, aerr.Code(); e != a {
if e, a := aws.ErrCodeRequestCanceled, aerr.Code(); e != a {
t.Errorf("expected error code %q, got %q", e, a)
}
if e, a := "canceled", aerr.Message(); !strings.Contains(a, e) {
Expand Down
2 changes: 1 addition & 1 deletion service/s3/s3manager/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ func TestDownloadWithContextCanceled(t *testing.T) {
t.Fatalf("expected error, did not get one")
}
aerr := err.(awserr.Error)
if e, a := request.CanceledErrorCode, aerr.Code(); e != a {
if e, a := request.ErrCodeRequestCanceled, aerr.Code(); e != a {
t.Errorf("expected error code %q, got %q", e, a)
}
if e, a := "canceled", aerr.Message(); !strings.Contains(a, e) {
Expand Down
2 changes: 1 addition & 1 deletion service/s3/s3manager/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ func TestUploadWithContextCanceled(t *testing.T) {
t.Fatalf("expected error, did not get one")
}
aerr := err.(awserr.Error)
if e, a := request.CanceledErrorCode, aerr.Code(); e != a {
if e, a := request.ErrCodeRequestCanceled, aerr.Code(); e != a {
t.Errorf("expected error code %q, got %q", e, a)
}
if e, a := "canceled", aerr.Message(); !strings.Contains(a, e) {
Expand Down