mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
Improve the error diagnostics within xmlrpclib2 in order to be more defensive
against internal errors. Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
This commit is contained in:
1 parent
9ff1710953
commit
a69027d845
1 file changed
+19
-16
@@ -227,24 +227,27 @@ class TCPXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer):
|
||||
response = xmlrpclib.dumps(response,
|
||||
methodresponse=1,
|
||||
allow_none=1)
|
||||
except xmlrpclib.Fault, fault:
|
||||
response = xmlrpclib.dumps(fault)
|
||||
except Exception, exn:
|
||||
if self.xenapi:
|
||||
if _is_not_supported(exn):
|
||||
errdesc = ['MESSAGE_METHOD_UNKNOWN', method]
|
||||
try:
|
||||
if self.xenapi:
|
||||
if _is_not_supported(exn):
|
||||
errdesc = ['MESSAGE_METHOD_UNKNOWN', method]
|
||||
else:
|
||||
log.exception('Internal error handling %s', method)
|
||||
errdesc = ['INTERNAL_ERROR', str(exn)]
|
||||
|
||||
response = xmlrpclib.dumps(
|
||||
({ "Status": "Failure",
|
||||
"ErrorDescription": errdesc },),
|
||||
methodresponse = 1)
|
||||
else:
|
||||
log.exception('Internal error handling %s', method)
|
||||
errdesc = ['INTERNAL_ERROR', str(exn)]
|
||||
response = xmlrpclib.dumps(
|
||||
({ "Status": "Failure",
|
||||
"ErrorDescription": errdesc },),
|
||||
methodresponse = 1)
|
||||
else:
|
||||
log.exception('Internal error handling %s', method)
|
||||
import xen.xend.XendClient
|
||||
response = xmlrpclib.dumps(
|
||||
xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, str(exn)))
|
||||
import xen.xend.XendClient
|
||||
response = xmlrpclib.dumps(
|
||||
xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, str(exn)))
|
||||
except:
|
||||
log.exception('Internal error handling error')
|
||||
|
||||
return response
|
||||
|
||||
|
||||
@@ -253,7 +256,7 @@ def _is_not_supported(exn):
|
||||
try:
|
||||
m = notSupportedRE.search(exn[0])
|
||||
return m is not None
|
||||
except TypeError, e:
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
|
||||