Proper display of XMLRPCserver exceptions

  • Thread starter Jean-Michel Pichavant
  • Start date
J

Jean-Michel Pichavant

To all using xmlrpclib,

I had trouble getting a proper display of my exceptions occuring on the
server. Basically, xmlrpclib only display the exception itself without
any traceback, on the client side.

Something like
<Fault 1: "<type 'exceptions.KeyError'>:2">

Ok then there's a key error, but how the hell am I supposed to know
where it occured ?

So I wrote this:
from SimpleXMLRPCServer import SimpleXMLRPCServer
server = SimpleXMLRPCServer(('localhost', 8000), logRequests=False,
allow_none=True)
old_dispatch = server._dispatch
def _new_dispatch(method, params):
try:
return old_dispatch(method,params)
except Exception, exc:
import traceback
traceback.print_exc()
raise
server._dispatch = _new_dispatch


Pretty dirty, isn't it, accessing the private attributes (too lazy to
subclass) ! I guess there's an obvious way to do this with xmlrpclib
that I just missed. Anyone knows ?

JM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top