On Mon, Nov 7, 2011 at 12:52 PM, Gerhardus Geldenhuis <gerhardus.geldenh...@gmail.com> wrote: > 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 >
It depends on the specific library used. Generally, the type of the exception, sometimes in conjunction with the error message, will tell you what went wrong. In this case, the xmlrpclib.Fault exception represents all XML-RPC Faults, and there are faultCode and faultString attributes to figure out where it went wrong. See also the xmlrpclib documentation (docs are your friend!) http://docs.python.org/library/xmlrpclib.html#fault-objects HTH, Hugo _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor