When using xmlrpclib in python an error on the server side is reported by the client side as an xmlrpclib.Fault. A division by zero error in a method on the server side (using SimpleXMLRPCServer) usually gives an output like the following:
xmlrpclib.Fault: <Fault 1: "<type 'exceptions.ZeroDivisionError'>:integer division or modulo by zero">
This is useful as it notes the type of error, but now where it happened. How is it possible to overwrite/modify the xmlrpclib.Fault method (in SimpleXMLRPCServer?) so it reports the error e.g. as follows:
xmlrpclib.Fault: <Fault 1: "<type 'exceptions.ZeroDivisionError'>:integer division or modulo by zero MODULE: myMethod.py LINE: 657">
i.e. to include the name of the module the error appeared and the line number. Is that possible to do on the server-side, without raising custom exceptions? ANY error should reported in the same way on the client side.
If you use
SimpleXMLRPCServer, you can override the internal_marshaled_dispatchmethod to add information to theFault()instance generated:This is the original method:
You can subclass
SimpleXMLRPCServer.SimpleXMLRPCServerand override this method:Then use
VerboseFaultXMLRPCServerinstead ofSimpleXMLRPCServer.SimpleXMLRPCServer.