Skip to content

Commit

Permalink
include transport-level detail in fault data
Browse files Browse the repository at this point in the history
  • Loading branch information
nitzmahone committed Dec 4, 2017
1 parent e1894ca commit 185bd19
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions winrm/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ def send_message(self, message):

fault = root.find('soapenv:Body/soapenv:Fault', xmlns)
if fault is not None:
fault_data = {}
fault_data = dict(
transport_message=ex.message,
http_status_code=ex.code
)
wsmanfault_code = fault.find('soapenv:Detail/wsmanfault:WSManFault[@Code]', xmlns)
if wsmanfault_code is not None:
fault_data['wsmanfault_code'] = wsmanfault_code.get('Code')
Expand All @@ -254,7 +257,7 @@ def send_message(self, message):
else:
error_message = "(no error message in fault)"

raise WinRMError('{0} (fault_data: {1})'.format(error_message, fault_data))
raise WinRMError('{0} (extended fault data: {1})'.format(error_message, fault_data))

def close_shell(self, shell_id):
"""
Expand Down

0 comments on commit 185bd19

Please sign in to comment.