direct-io.hg

changeset 14447:8b527e3d27d6

Improve the error diagnostics within xmlrpclib2 in order to be more defensive
against internal errors.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
author Ewan Mellor <ewan@xensource.com>
date Tue Mar 20 11:34:14 2007 +0000 (2007-03-20)
parents 129bc1eda8d0
children dace880e871a
files tools/python/xen/util/xmlrpclib2.py
line diff
     1.1 --- a/tools/python/xen/util/xmlrpclib2.py	Tue Mar 20 14:34:53 2007 +0000
     1.2 +++ b/tools/python/xen/util/xmlrpclib2.py	Tue Mar 20 11:34:14 2007 +0000
     1.3 @@ -227,24 +227,27 @@ class TCPXMLRPCServer(SocketServer.Threa
     1.4              response = xmlrpclib.dumps(response,
     1.5                                         methodresponse=1,
     1.6                                         allow_none=1)
     1.7 -        except xmlrpclib.Fault, fault:
     1.8 -            response = xmlrpclib.dumps(fault)
     1.9          except Exception, exn:
    1.10 -            if self.xenapi:
    1.11 -                if _is_not_supported(exn):
    1.12 -                    errdesc = ['MESSAGE_METHOD_UNKNOWN', method]
    1.13 +            try:
    1.14 +                if self.xenapi:
    1.15 +                    if _is_not_supported(exn):
    1.16 +                         errdesc = ['MESSAGE_METHOD_UNKNOWN', method]
    1.17 +                    else:
    1.18 +                         log.exception('Internal error handling %s', method)
    1.19 +                         errdesc = ['INTERNAL_ERROR', str(exn)]
    1.20 +
    1.21 +                    response = xmlrpclib.dumps(
    1.22 +                          ({ "Status": "Failure",
    1.23 +                             "ErrorDescription": errdesc },),
    1.24 +                          methodresponse = 1)
    1.25                  else:
    1.26                      log.exception('Internal error handling %s', method)
    1.27 -                    errdesc = ['INTERNAL_ERROR', str(exn)]
    1.28 -                response = xmlrpclib.dumps(
    1.29 -                    ({ "Status": "Failure",
    1.30 -                       "ErrorDescription": errdesc },),
    1.31 -                    methodresponse = 1)
    1.32 -            else:
    1.33 -                log.exception('Internal error handling %s', method)
    1.34 -                import xen.xend.XendClient
    1.35 -                response = xmlrpclib.dumps(
    1.36 -                    xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, str(exn)))
    1.37 +                    import xen.xend.XendClient
    1.38 +                    response = xmlrpclib.dumps(
    1.39 +                       xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, str(exn)))
    1.40 +            except:
    1.41 +                log.exception('Internal error handling error')
    1.42 +
    1.43          return response
    1.44  
    1.45  
    1.46 @@ -253,7 +256,7 @@ def _is_not_supported(exn):
    1.47      try:
    1.48          m = notSupportedRE.search(exn[0])
    1.49          return m is not None
    1.50 -    except TypeError, e:
    1.51 +    except:
    1.52          return False
    1.53  
    1.54