heat API : Return correct AWS error response for invalid parameter

Passing template parameter values which are not in AllowedValues
makes the engine throw a ValueError exception, which should be
mapped back to HeatInvalidParameterValueError so that the API
error response is correctly formatted.

Fixes #180

Change-Id: I8615cb7fbbbfd21a403a4973fe0a63300c6cf852
Signed-off-by: Steven Hardy <shardy@redhat.com>
This commit is contained in:
Steven Hardy 2012-07-27 14:43:37 +01:00
parent e3e011b9cb
commit c69f3892c2

View File

@ -72,8 +72,8 @@ class StackController(object):
to HeatAPIException subclasses which can be used to return
properly formatted AWS error responses
"""
if ex.exc_type == 'AttributeError':
# Attribute error, bad user data, ex.value should tell us why
if ex.exc_type in ('AttributeError', 'ValueError'):
# Attribute/Value error, bad user data, ex.value should tell us why
return exception.HeatInvalidParameterValueError(detail=ex.value)
else:
# Map everything else to internal server error for now