~ubuntu-branches/ubuntu/wily/heat/wily-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): James Page, Corey Bryant, James Page
  • Date: 2015-03-30 11:11:18 UTC
  • mfrom: (1.1.23)
  • Revision ID: package-import@ubuntu.com-20150330111118-2qpycylx6swu4yhj
Tags: 2015.1~b3-0ubuntu1
[ Corey Bryant ]
* New upstream milestone release for OpenStack kilo:
  - d/control: Align with upstream dependencies.
  - d/p/sudoers_patch.patch: Rebased.
  - d/p/fix-requirements.patch: Rebased.

[ James Page ]
* d/p/fixup-assert-regex.patch: Tweak test to use assertRegexpMatches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
import traceback
25
25
 
26
 
from oslo.config import cfg
 
26
from oslo_config import cfg
27
27
import webob
28
28
 
29
29
from heat.common import exception
31
31
from heat.common import wsgi
32
32
 
33
33
 
34
 
cfg.CONF.import_opt('debug', 'heat.openstack.common.log')
35
 
 
36
 
 
37
34
class Fault(object):
38
35
 
39
36
    def __init__(self, error):
87
84
        'Invalid': webob.exc.HTTPBadRequest,
88
85
        'ResourcePropertyConflict': webob.exc.HTTPBadRequest,
89
86
        'PropertyUnspecifiedError': webob.exc.HTTPBadRequest,
 
87
        'ObjectFieldInvalid': webob.exc.HTTPBadRequest,
 
88
        'ReadOnlyFieldError': webob.exc.HTTPBadRequest,
 
89
        'ObjectActionError': webob.exc.HTTPBadRequest,
 
90
        'IncompatibleObjectVersion': webob.exc.HTTPBadRequest,
 
91
        'OrphanedObjectError': webob.exc.HTTPBadRequest,
 
92
        'UnsupportedObjectError': webob.exc.HTTPBadRequest,
90
93
    }
91
94
 
92
95
    def _map_exception_to_error(self, class_exception):
101
104
    def _error(self, ex):
102
105
 
103
106
        trace = None
 
107
        traceback_marker = 'Traceback (most recent call last)'
104
108
        webob_exc = None
105
109
        if isinstance(ex, exception.HTTPExceptionDisguise):
106
110
            # An HTTP exception was disguised so it could make it here
117
121
            ex_type = ex_type[:-len('_Remote')]
118
122
 
119
123
        full_message = six.text_type(ex)
120
 
        if full_message.find('\n') > -1 and is_remote:
 
124
        if '\n' in full_message and is_remote:
121
125
            message, msg_trace = full_message.split('\n', 1)
 
126
        elif traceback_marker in full_message:
 
127
            message, msg_trace = full_message.split(traceback_marker, 1)
 
128
            message = message.rstrip('\n')
 
129
            msg_trace = traceback_marker + msg_trace
122
130
        else:
123
131
            msg_trace = traceback.format_exc()
124
132
            message = full_message