~ubuntu-branches/ubuntu/vivid/ironic/vivid-updates

« back to all changes in this revision

Viewing changes to ironic/api/middleware/parsable_error.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-01-05 12:21:37 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20150105122137-171bqrdpcxqipunk
Tags: 2015.1~b1-0ubuntu1
* New upstream beta release:
  - d/control: Align version requirements with upstream release.
* d/watch: Update uversionmangle to deal with kilo beta versioning
  changes.
* d/control: Bumped Standards-Version to 3.9.6, no changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
"""
24
24
 
25
25
import json
 
26
from xml import etree as et
 
27
 
26
28
import webob
27
 
from xml import etree as et
28
29
 
29
30
from ironic.common.i18n import _
30
31
from ironic.common.i18n import _LE
34
35
 
35
36
 
36
37
class ParsableErrorMiddleware(object):
37
 
    """Replace error body with something the client can parse.
38
 
    """
 
38
    """Replace error body with something the client can parse."""
39
39
    def __init__(self, app):
40
40
        self.app = app
41
41
 
45
45
        state = {}
46
46
 
47
47
        def replacement_start_response(status, headers, exc_info=None):
48
 
            """Overrides the default response to make errors parsable.
49
 
            """
 
48
            """Overrides the default response to make errors parsable."""
50
49
            try:
51
50
                status_code = int(status.split(' ')[0])
52
51
                state['status_code'] = status_code