[Tutor] Handling exceptions

Gerhardus Geldenhuis gerhardus.geldenhuis at gmail.com
Mon Nov 7 12:52:24 CET 2011


Hi
I am trying to handle exceptions for a xmlrpc class interfacing with
cobbler.

The exception:

 xmlrpclib.Fault: <Fault 1: "cobbler.cexceptions.CX:'invalid profile name:
test_profile'">


and the experimental code.

  try:
    server = xmlrpclib.Server("http://192.168.2.11/cobbler_api")
    #...
  except xmlrpclib.Fault as detail:

    print 'xmlrpc error'
    print detail
#    print detail.arguments
    print repr(detail)

I don't understand what I am getting from the exception. Do I only get a
string and is the above snippet a good/clean/nice way of handling it. If I
only get a string then it is likely that I will have to have  few if's to
handle the various error strings returned.

Regards

-- 
Gerhardus Geldenhuis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111107/122191bd/attachment.html>


More information about the Tutor mailing list