CLIENT,SERVER: improve error message on client side
bzr revid: ced-6733fdd8bfd68743d3edaedf0d36da74287f11b8
This commit is contained in:
parent
93bcf9f92d
commit
881fa80438
|
@ -209,14 +209,15 @@ class GenericXMLRPCRequestHandler:
|
|||
return r
|
||||
except Exception,e:
|
||||
logger = Logger()
|
||||
logger.notifyChannel("web-services", LOG_ERROR, 'Exception in call: ' + reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)))
|
||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||
logger.notifyChannel("web-services", LOG_ERROR, 'Exception in call: ' + tb_s)
|
||||
s=str(e)
|
||||
import tools
|
||||
if tools.config['debug_mode']:
|
||||
import pdb
|
||||
tb = sys.exc_info()[2]
|
||||
pdb.post_mortem(tb)
|
||||
raise xmlrpclib.Fault(1,s)
|
||||
raise xmlrpclib.Fault(s, tb_s)
|
||||
|
||||
class SimpleXMLRPCRequestHandler(GenericXMLRPCRequestHandler, SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
|
||||
pass
|
||||
|
@ -305,14 +306,15 @@ class TinySocketClientThread(threading.Thread):
|
|||
ts.mysend(r)
|
||||
except Exception, e:
|
||||
logger = Logger()
|
||||
logger.notifyChannel("web-services", LOG_ERROR, 'Exception in call: ' + reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)))
|
||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||
logger.notifyChannel("web-services", LOG_ERROR, 'Exception in call: ' + tb_s)
|
||||
s=str(e)
|
||||
import tools
|
||||
if tools.config['debug_mode']:
|
||||
import pdb
|
||||
tb = sys.exc_info()[2]
|
||||
pdb.post_mortem(tb)
|
||||
ts.mysend(e, exception=True)
|
||||
ts.mysend(e, exception=True, traceback=tb_s)
|
||||
self.sock.close()
|
||||
self.threads.remove(self)
|
||||
return True
|
||||
|
|
|
@ -23,8 +23,8 @@ class mysocket:
|
|||
def disconnect(self):
|
||||
self.sock.shutdown(socket.SHUT_RDWR)
|
||||
self.sock.close()
|
||||
def mysend(self, msg, exception=False):
|
||||
msg = cPickle.dumps(msg)
|
||||
def mysend(self, msg, exception=False, traceback=None):
|
||||
msg = cPickle.dumps([msg,traceback])
|
||||
size = len(msg)
|
||||
self.sock.send('%8d' % size)
|
||||
self.sock.send(exception and "1" or "0")
|
||||
|
@ -54,9 +54,10 @@ class mysocket:
|
|||
raise RuntimeError, "socket connection broken"
|
||||
msg = msg + chunk
|
||||
res = cPickle.loads(msg)
|
||||
if isinstance(res,Exception):
|
||||
if isinstance(res[0],Exception):
|
||||
if exception:
|
||||
raise Myexception(exception, str(res))
|
||||
raise res
|
||||
raise Myexception(exception, str(res[0]), str(res[1]))
|
||||
raise res[0]
|
||||
else:
|
||||
return res
|
||||
return res[0]
|
||||
|
||||
|
|
Loading…
Reference in New Issue