0

I have a java web service and python client using suds. My server raises custom exceptions which I would like to handle in the python script. Is it possible to catch them or it always will be caught as suds.WebFault exception?

1 Answer 1

1

suds.WebFault has fault field that has information about fault.

except suds.WebFault, e:
    print e.fault.faultstring
    print e.document

You can have your program to analyze server custom exception from WebFault and create new exception class(es) for every specific server exception then catch suds.WebFault exception, read server exception details and raise your custom exception.

class MyException(suds.WebFault):
    pass


def convertServerException(e):
    if e.fault.faultstring == 'exception1':
        return MyException()
        #...add more exception handling cases here

#...
try:
#...make a WebService call
except suds.WebFault, e:
    print e
    print e.fault
    raise convertServerException(e)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.