Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changes/2212.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Exposed the response body of :exc:`zhmcclient.HTTPError` as a new `body`
property.
1 change: 1 addition & 0 deletions tests/unit/zhmcclient/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ def test_httperror_initial_attrs(arg_names, args):
body.get('request-body-as-string-partial', None)
assert exc.stack == body.get('stack', None)
assert exc.error_details == body.get('error-details', None)
assert exc.body == body


@pytest.mark.parametrize(
Expand Down
7 changes: 7 additions & 0 deletions zhmcclient/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,13 @@ def __init__(self, body):
super().__init__(msg)
self._body = body

@property
def body(self):
"""
:term:`json object`: Body of the HTTP error response.
"""
return self._body

@property
def http_status(self):
"""
Expand Down
Loading