to HeatAPIException subclasses which can be used to return
properly formatted AWS error responses
"""
- if ex.exc_type in ('AttributeError', 'ValueError'):
- # Attribute/Value error, bad user data, ex.value should tell us why
+ inval_param_errors = (
+ 'AttributeError',
+ 'ValueError',
+ )
+
+ if ex.exc_type in inval_param_errors:
return HeatInvalidParameterValueError(detail=ex.value)
else:
# Map everything else to internal server error for now
- # FIXME : further investigation into engine errors required
return HeatInternalFailureError(detail=ex.value)
to webob exceptions which can be used to return
properly formatted error responses.
"""
- if ex.exc_type in ('AttributeError', 'ValueError'):
- if force_exists:
- raise exc.HTTPBadRequest(explanation=str(ex))
- else:
- raise exc.HTTPNotFound(explanation=str(ex))
- raise exc.HTTPInternalServerError(explanation=str(ex))
+ client_error = exc.HTTPBadRequest if force_exists else exc.HTTPNotFound
+ error_map = {
+ 'AttributeError': client_error,
+ 'ValueError': client_error,
+ }
+
+ Exc = error_map.get(ex.exc_type, exc.HTTPInternalServerError)
+
+ raise Exc(explanation=str(ex))
from nose.plugins.attrib import attr
from heat.common import context
+from heat.common import exception
from heat.tests.v1_1 import fakes
import heat.engine.api as engine_api
import heat.db as db_api