document convertFault method

Update the convertFault docstring to describe how the method converts
faults, the "fault" parameter type, and possible return values.
This commit is contained in:
Ken Dreyer 2021-10-12 14:27:36 -04:00
parent 52ae5616dc
commit 0747714f6e

View file

@ -437,9 +437,18 @@ class MultiCallInProgress(object):
pass
# A function to get create an exception from a fault
def convertFault(fault):
"""Convert a fault to the corresponding Exception type, if possible"""
"""Convert a fault to the corresponding Exception type, if possible.
This method compares this fault's faultCode to all the known faultCodes
in the GenericError and sub-classes defined above. If there is a matching
faultCode, return that new Exception class. If there is no match, just
return the fault object as-is.
:param xmlrpc.client.Fault fault: The XML-RPC fault from the hub.
:returns: one of the GenericError sub-classes, if possible.
:returns: fault instance, if no GenericError sub-classes matched.
"""
code = getattr(fault, 'faultCode', None)
if code is None:
return fault