adding first error handling

This commit is contained in:
zmsmith 2013-03-10 15:46:27 -04:00
commit 1cc0e0eac7
2 changed files with 16 additions and 1 deletions

View file

@ -21,6 +21,9 @@ class DynamoHandler(object):
if match:
return match.split(".")[1]
def error(self, type_, status=400):
return json.dumps({'__type': type_}), dict(status=400)
def dispatch(self):
method = self.get_method_name(self.headers)
if method:
@ -35,7 +38,11 @@ class DynamoHandler(object):
def DescribeTable(self, uri, body, headers):
name = json.loads(body)['TableName']
table = dynamodb_backend.tables[name]
try:
table = dynamodb_backend.tables[name]
except KeyError:
er = 'com.amazonaws.dynamodb.v20111205#ResourceNotFoundException'
return self.error(er)
return json.dumps(table.describe)