Merge "Map RequestLimitExceeded exception in heat-cfn-api"

This commit is contained in:
Jenkins 2016-03-02 04:11:19 +00:00 committed by Gerrit Code Review
commit 31c39e74b0
2 changed files with 17 additions and 0 deletions

View File

@ -273,6 +273,15 @@ class HeatActionInProgressError(HeatAPIException):
"in progress")
class HeatRequestLimitExceeded(HeatAPIException):
"""Payload size of the request exceeds maximum allowed size."""
code = 400
title = 'RequestLimitExceeded'
explanation = _("Payload exceeds maximum allowed size")
def map_remote_error(ex):
"""Map rpc_common.RemoteError exceptions to HeatAPIException subclasses.
@ -306,6 +315,7 @@ def map_remote_error(ex):
denied_errors = ('Forbidden', 'NotAuthorized')
already_exists_errors = ('StackExists')
invalid_action_errors = ('ActionInProgress',)
request_limit_exceeded = ('RequestLimitExceeded')
ex_type = ex.__class__.__name__
@ -320,6 +330,8 @@ def map_remote_error(ex):
return AlreadyExistsError(detail=six.text_type(ex))
elif ex_type in invalid_action_errors:
return HeatActionInProgressError(detail=six.text_type(ex))
elif ex_type in request_limit_exceeded:
return HeatRequestLimitExceeded(detail=six.text_type(ex))
else:
# Map everything else to internal server error for now
return HeatInternalFailureError(detail=six.text_type(ex))

View File

@ -218,3 +218,8 @@ class AWSCommonTest(common.HeatTestCase):
action="testing")
expected = aws_exception.HeatActionInProgressError
self.assertIsInstance(aws_exception.map_remote_error(ex), expected)
def test_map_remote_error_request_limit_exceeded(self):
ex = common_exception.RequestLimitExceeded(message="testing")
expected = aws_exception.HeatRequestLimitExceeded
self.assertIsInstance(aws_exception.map_remote_error(ex), expected)