Class: Aws::S3::Errors::PermanentRedirect

Inherits:
ServiceError
  • Object
show all
Defined in:
lib/aws-sdk-s3/customizations/errors.rb

Overview

Hijack PermanentRedirect dynamic error to also include endpoint and bucket.

Instance Method Summary collapse

Constructor Details

#initialize(context, message, _data = Aws::EmptyStructure.new) ⇒ PermanentRedirect

Returns a new instance of PermanentRedirect.

Parameters:



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/aws-sdk-s3/customizations/errors.rb', line 12

def initialize(context, message, _data = Aws::EmptyStructure.new)
  data = Aws::S3::Types::PermanentRedirect.new(message: message)
  body = context.http_response.body_contents
  if (endpoint = body.match(/<Endpoint>(.+?)<\/Endpoint>/))
    data.endpoint = endpoint[1]
  end
  if (bucket = body.match(/<Bucket>(.+?)<\/Bucket>/))
    data.bucket = bucket[1]
  end
  data.region = context.http_response.headers['x-amz-bucket-region']
  super(context, message, data)
end