diff options
author | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
---|---|---|
committer | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
commit | 107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch) | |
tree | ca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error.go | |
parent | 844b5a68d8af4791755b8f0ad293cc99f5959183 (diff) | |
download | terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip |
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error.go')
-rw-r--r-- | vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error.go | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error.go b/vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error.go index bcca862..1db7e13 100644 --- a/vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error.go +++ b/vendor/github.com/aws/aws-sdk-go/service/s3/unmarshal_error.go | |||
@@ -23,22 +23,22 @@ func unmarshalError(r *request.Request) { | |||
23 | defer r.HTTPResponse.Body.Close() | 23 | defer r.HTTPResponse.Body.Close() |
24 | defer io.Copy(ioutil.Discard, r.HTTPResponse.Body) | 24 | defer io.Copy(ioutil.Discard, r.HTTPResponse.Body) |
25 | 25 | ||
26 | hostID := r.HTTPResponse.Header.Get("X-Amz-Id-2") | ||
27 | |||
28 | // Bucket exists in a different region, and request needs | 26 | // Bucket exists in a different region, and request needs |
29 | // to be made to the correct region. | 27 | // to be made to the correct region. |
30 | if r.HTTPResponse.StatusCode == http.StatusMovedPermanently { | 28 | if r.HTTPResponse.StatusCode == http.StatusMovedPermanently { |
31 | r.Error = requestFailure{ | 29 | msg := fmt.Sprintf( |
32 | RequestFailure: awserr.NewRequestFailure( | 30 | "incorrect region, the bucket is not in '%s' region at endpoint '%s'", |
33 | awserr.New("BucketRegionError", | 31 | aws.StringValue(r.Config.Region), |
34 | fmt.Sprintf("incorrect region, the bucket is not in '%s' region", | 32 | aws.StringValue(r.Config.Endpoint), |
35 | aws.StringValue(r.Config.Region)), | 33 | ) |
36 | nil), | 34 | if v := r.HTTPResponse.Header.Get("x-amz-bucket-region"); len(v) != 0 { |
37 | r.HTTPResponse.StatusCode, | 35 | msg += fmt.Sprintf(", bucket is in '%s' region", v) |
38 | r.RequestID, | ||
39 | ), | ||
40 | hostID: hostID, | ||
41 | } | 36 | } |
37 | r.Error = awserr.NewRequestFailure( | ||
38 | awserr.New("BucketRegionError", msg, nil), | ||
39 | r.HTTPResponse.StatusCode, | ||
40 | r.RequestID, | ||
41 | ) | ||
42 | return | 42 | return |
43 | } | 43 | } |
44 | 44 | ||
@@ -63,14 +63,11 @@ func unmarshalError(r *request.Request) { | |||
63 | errMsg = statusText | 63 | errMsg = statusText |
64 | } | 64 | } |
65 | 65 | ||
66 | r.Error = requestFailure{ | 66 | r.Error = awserr.NewRequestFailure( |
67 | RequestFailure: awserr.NewRequestFailure( | 67 | awserr.New(errCode, errMsg, err), |
68 | awserr.New(errCode, errMsg, err), | 68 | r.HTTPResponse.StatusCode, |
69 | r.HTTPResponse.StatusCode, | 69 | r.RequestID, |
70 | r.RequestID, | 70 | ) |
71 | ), | ||
72 | hostID: hostID, | ||
73 | } | ||
74 | } | 71 | } |
75 | 72 | ||
76 | // A RequestFailure provides access to the S3 Request ID and Host ID values | 73 | // A RequestFailure provides access to the S3 Request ID and Host ID values |
@@ -83,21 +80,3 @@ type RequestFailure interface { | |||
83 | // Host ID is the S3 Host ID needed for debug, and contacting support | 80 | // Host ID is the S3 Host ID needed for debug, and contacting support |
84 | HostID() string | 81 | HostID() string |
85 | } | 82 | } |
86 | |||
87 | type requestFailure struct { | ||
88 | awserr.RequestFailure | ||
89 | |||
90 | hostID string | ||
91 | } | ||
92 | |||
93 | func (r requestFailure) Error() string { | ||
94 | extra := fmt.Sprintf("status code: %d, request id: %s, host id: %s", | ||
95 | r.StatusCode(), r.RequestID(), r.hostID) | ||
96 | return awserr.SprintError(r.Code(), r.Message(), extra, r.OrigErr()) | ||
97 | } | ||
98 | func (r requestFailure) String() string { | ||
99 | return r.Error() | ||
100 | } | ||
101 | func (r requestFailure) HostID() string { | ||
102 | return r.hostID | ||
103 | } | ||