I'm trying to pass arbitrary exceptions from a XMLRPC server to a client (both Python scripts, exception types are defined on both sides). There's an exemplary client-side implementation at ActiveState Recipes which parses the returned "faultString", compares it with a list of known exceptions and, if found, raises that exception (instead of wrapping it in a xmlrpclib.Fault
).
Example of an XMLRPC exception response:
<?xml version='1.0'?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value>
<int>1</int>
</value>
</member>
<member>
<name>faultString</name>
<value>
<string>ValueError:</string>
</value>
</member>
</struct>
</value>
</fault>
</methodResponse>
The ActiveState recipe splits the "ValueError:" string and compares "ValueError" with ValueError.__name__
(which is in allowed_errors = [ValueError, TypeError]
, cf. link above).
Is it possible to pass all exceptions like this, i.e. automatically raise any exception (derived from Exception
or some other base class) on the client side (after it was raised on the server)?
The ActiveState script works, but I don't want to register every single exception that could be thrown (must be in allowed_errors
).
(Bonus question: Is there another technology apart from XMLRPC that could handle this problem properly? Pyro?)