All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: xen-devel@lists.xensource.com
Cc: Ewan Mellor <ewan@xensource.com>
Subject: Re: [Xen-changelog] Improve error handling, in particular fixing the ProtocolError that is thrown
Date: Thu, 23 Mar 2006 14:11:07 -0600	[thread overview]
Message-ID: <442300DB.1020004@us.ibm.com> (raw)
In-Reply-To: <E1FMQAe-0001GC-KH@xenbits.xensource.com>

Xen patchbot -unstable wrote:
> # HG changeset patch
> # User emellor@leeni.uk.xensource.com
> # Node ID da24df1ea484cf72dc9d367d52e828777e0e20cd
> # Parent  c1bb4eb565296bdb00aed84fcc877befbcebd8e9
> Improve error handling, in particular fixing the ProtocolError that is thrown
> when a domain is specified by the user that does not exist.  Added a few
> error codes -- many more to come, I expect.
>
> Signed-off-by: Ewan Mellor <ewan@xensource.com>
>
> diff -r c1bb4eb56529 -r da24df1ea484 tools/python/xen/xend/server/XMLRPCServer.py
> --- a/tools/python/xen/xend/server/XMLRPCServer.py	Thu Mar 23 10:58:19 2006
> +++ b/tools/python/xen/xend/server/XMLRPCServer.py	Thu Mar 23 11:59:43 2006
> @@ -13,25 +13,45 @@
>  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>  #============================================================================
>  # Copyright (C) 2006 Anthony Liguori <aliguori@us.ibm.com>
> -# Copyright (C) 2006 XenSource Ltd
> +# Copyright (C) 2006 XenSource Ltd.
>  #============================================================================
> +
> +import xmlrpclib
>  
>  from xen.xend import XendDomain, XendDomainInfo, XendNode, \
>                       XendLogging, XendDmesg
>  from xen.util.xmlrpclib2 import UnixXMLRPCServer, TCPXMLRPCServer
>  
> -from xen.xend.XendClient import XML_RPC_SOCKET
> +from xen.xend.XendClient import XML_RPC_SOCKET, ERROR_INVALID_DOMAIN
>  
>  def lookup(domid):
> -    return XendDomain.instance().domain_lookup_by_name_or_id(domid)
> +    try:
> +        return XendDomain.instance().domain_lookup_by_name_or_id(domid)
> +    except exn:
> +        log.exception(exn)
> +        raise exn
>  
>  def dispatch(domid, fn, args):
>      info = lookup(domid)
> -    return getattr(info, fn)(*args)
> +    if info:
> +        try:
> +            return getattr(info, fn)(*args)
> +        except exn:
> +            log.exception(exn)
>   

log doesn't appear to be defined in this scope.

Also, there appears to be a problem with the except syntax.  Don't you mean:

except Exception, exn:

Regards,

Anthony Liguori

> +            raise exn
> +    else:
> +        raise xmlrpclib.Fault(ERROR_INVALID_DOMAIN, domid)
>  
>  def domain(domid):
>      info = lookup(domid)
> -    return info.sxpr()
> +    if info:
> +        try:
> +            return info.sxpr()
> +        except exn:
> +            log.exception(exn)
> +            raise exn
> +    else:
> +        raise xmlrpclib.Fault(ERROR_INVALID_DOMAIN, domid)
>  
>  def domains(detail=1):
>      if detail < 1:
> diff -r c1bb4eb56529 -r da24df1ea484 tools/python/xen/xm/main.py
> --- a/tools/python/xen/xm/main.py	Thu Mar 23 10:58:19 2006
> +++ b/tools/python/xen/xm/main.py	Thu Mar 23 11:59:43 2006
> @@ -1,6 +1,6 @@
>  # (C) Copyright IBM Corp. 2005
>  # Copyright (C) 2004 Mike Wray
> -# Copyright (c) 2005 XenSource Ltd
> +# Copyright (c) 2005-2006 XenSource Ltd.
>  #
>  # Authors:
>  #     Sean Dague <sean at dague dot net>
> @@ -38,7 +38,7 @@
>  from xen.xm.opts import *
>  
>  import console
> -
> +import xen.xend.XendClient
>  from xen.xend.XendClient import server
>  
>  # getopt.gnu_getopt is better, but only exists in Python 2.3+.  Use
> @@ -1111,7 +1111,10 @@
>          except SystemExit:
>              sys.exit(1)
>          except xmlrpclib.Fault, ex:
> -            print "Error: %s" % ex.faultString
> +            if ex.faultCode == xen.xend.XendClient.ERROR_INVALID_DOMAIN:
> +                print "Error: the domain '%s' does not exist." % ex.faultString
> +            else:
> +                print "Error: %s" % ex.faultString
>              sys.exit(1)
>          except:
>              print "Unexpected error:", sys.exc_info()[0]
>
> _______________________________________________
> Xen-changelog mailing list
> Xen-changelog@lists.xensource.com
> http://lists.xensource.com/xen-changelog
>   

           reply	other threads:[~2006-03-23 20:11 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <E1FMQAe-0001GC-KH@xenbits.xensource.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=442300DB.1020004@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=ewan@xensource.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.