~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to heat/api/middleware/fault.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-10-03 09:43:04 UTC
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: package-import@ubuntu.com-20131003094304-zhhr2brapzlpvjmm
Tags: upstream-2013.2~rc1
ImportĀ upstreamĀ versionĀ 2013.2~rc1

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import traceback
24
24
import webob
 
25
from oslo.config import cfg
 
26
 
 
27
cfg.CONF.import_opt('debug', 'heat.openstack.common.log')
25
28
 
26
29
from heat.common import exception
27
30
from heat.openstack.common import log as logging
71
74
        'NotSupported': webob.exc.HTTPBadRequest,
72
75
        'MissingCredentialError': webob.exc.HTTPBadRequest,
73
76
        'UserParameterMissing': webob.exc.HTTPBadRequest,
 
77
        'RequestLimitExceeded': webob.exc.HTTPBadRequest,
74
78
    }
75
79
 
76
80
    def _error(self, ex):
80
84
        if isinstance(ex, exception.HTTPExceptionDisguise):
81
85
            # An HTTP exception was disguised so it could make it here
82
86
            # let's remove the disguise and set the original HTTP exception
83
 
            trace = ''.join(traceback.format_tb(ex.tb))
 
87
            if cfg.CONF.debug:
 
88
                trace = ''.join(traceback.format_tb(ex.tb))
84
89
            ex = ex.exc
85
90
            webob_exc = ex
86
91
 
89
94
        if ex_type.endswith(rpc_common._REMOTE_POSTFIX):
90
95
            ex_type = ex_type[:-len(rpc_common._REMOTE_POSTFIX)]
91
96
 
92
 
        message = str(ex.message)
 
97
        message = unicode(ex.message)
93
98
 
94
 
        if not trace:
95
 
            trace = str(ex)
 
99
        if cfg.CONF.debug and not trace:
 
100
            trace = unicode(ex)
96
101
            if trace.find('\n') > -1:
97
102
                unused, trace = trace.split('\n', 1)
98
103
            else: