Skip to content

Commit

Permalink
Wrap api exceptions in _()
Browse files Browse the repository at this point in the history
Change-Id: Ie9a60d919b3657ae23fe2f8c67d18d21f571af14
Partial-bug: #1199695
  • Loading branch information
asalkeld committed Oct 18, 2013
1 parent a1ad083 commit 6895615
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
3 changes: 2 additions & 1 deletion heat/api/aws/ec2token.py
Expand Up @@ -166,7 +166,8 @@ def _authorize(self, req, auth_uri):
if not auth_uri:
logger.error("Ec2Token authorization failed, no auth_uri "
"specified in config file")
raise exception.HeatInternalFailureError("Service misconfigured")
raise exception.HeatInternalFailureError(_('Service '
'misconfigured'))
# Make a copy of args for authentication and signature verification.
auth_params = dict(req.params)
# 'Signature' param Not part of authentication args
Expand Down
8 changes: 4 additions & 4 deletions heat/api/cfn/v1/stacks.py
Expand Up @@ -54,15 +54,15 @@ def _enforce(self, req, action):
try:
self.policy.enforce(req.context, action, {})
except heat_exception.Forbidden:
raise exception.HeatAccessDeniedError("Action %s not allowed " %
action + "for user")
msg = _('Action %s not allowed for user') % action
raise exception.HeatAccessDeniedError(msg)
except Exception as ex:
# We expect policy.enforce to either pass or raise Forbidden
# however, if anything else happens, we want to raise
# HeatInternalFailureError, failure to do this results in
# the user getting a big stacktrace spew as an API response
raise exception.HeatInternalFailureError("Error authorizing " +
"action %s" % action)
msg = _('Error authorizing action %s') % action
raise exception.HeatInternalFailureError(msg)

@staticmethod
def _id_format(resp):
Expand Down
18 changes: 10 additions & 8 deletions heat/api/cloudwatch/watch.py
Expand Up @@ -47,15 +47,15 @@ def _enforce(self, req, action):
try:
self.policy.enforce(req.context, action, {})
except heat_exception.Forbidden:
raise exception.HeatAccessDeniedError("Action %s not allowed " %
action + "for user")
msg = _("Action %s not allowed for user") % action
raise exception.HeatAccessDeniedError(msg)
except Exception as ex:
# We expect policy.enforce to either pass or raise Forbidden
# however, if anything else happens, we want to raise
# HeatInternalFailureError, failure to do this results in
# the user getting a big stacktrace spew as an API response
raise exception.HeatInternalFailureError("Error authorizing " +
"action %s" % action)
msg = _("Error authorizing action %s") % action
raise exception.HeatInternalFailureError(msg)

@staticmethod
def _reformat_dimensions(dims):
Expand Down Expand Up @@ -319,10 +319,12 @@ def set_alarm_state(self, req):
state = api_utils.get_param_value(parms, 'StateValue')

if state not in state_map:
logger.error("Invalid state %s, expecting one of %s" %
(state, state_map.keys()))
return exception.HeatInvalidParameterValueError("Invalid state %s"
% state)
msg = _('Invalid state %(state)s, '
'expecting one of %(expect)s') % {
'state': state,
'expect': state_map.keys()}
logger.error(msg)
return exception.HeatInvalidParameterValueError(msg)

# Check for optional parameters
# FIXME : We don't actually do anything with these in the engine yet..
Expand Down

0 comments on commit 6895615

Please sign in to comment.