Module: AWS::DynamoDB::Errors::ModeledError

Defined in:
lib/aws/dynamo_db/errors.rb

Instance Method Summary collapse

Instance Method Details

#codeObject



45
46
47
48
# File 'lib/aws/dynamo_db/errors.rb', line 45

def code
  self.class.name =~ /(::)?([^:]+)$/
  $2
end

#extract_message(response) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/aws/dynamo_db/errors.rb', line 27

def extract_message(response)
  if response and response.body != ''
    JSON.load(response.body)["message"] || code
  elsif code == 'RequestEntityTooLarge'
    'Request body must be less than 1 MB'
  else
    code
  end
end

#include_error_type(response) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/aws/dynamo_db/errors.rb', line 37

def include_error_type(response)
  if response.status >= 500
    extend Errors::ServerError
  else
    extend Errors::ClientError
  end
end

#initialize(request = nil, response = nil) ⇒ Object



21
22
23
24
25
# File 'lib/aws/dynamo_db/errors.rb', line 21

def initialize(request = nil, response = nil)
  message = extract_message(response)
  include_error_type(response) if response
  super(request, response, message)
end