How to raise Suds.WebFault from python code?

I am trying to raise Suds.WebFault from python code. __init__The \ constructor method takes three arguments __init__(self, fault, document). The error has fault.faultcode and fault.detail members \ attributes \ properties. I could not understand which class matte belongs to, which I tried. How can I remove an exception like Suds.WebFault from python code?

Thanks in advance.

+5
source share
3 answers

Not sure what you are asking for, but you can clear the network error using:

import suds

try:
    client.service.Method(parameter)
except suds.WebFault, e:
    print e
+6
source

WebFault is defined suds.__init__.pyas:

class WebFault(Exception):
    def __init__(self, fault, document):
        if hasattr(fault, 'faultstring'):
            Exception.__init__(self, u"Server raised fault: '%s'" %
                fault.faultstring)
        self.fault = fault
        self.document = document

, WebFault , . None, .

import suds

class Fault(object): 
    faultstring = 'my error message'

raise suds.WebFault(Fault(), document=None)
+2

WebFault is only for actual promotion when the web server returns an item <Fault>. So it's probably a bad idea to pick it up on your own.

If you still want to, I will start to look at the code in which this creates the framework: https://github.com/unomena/suds/blob/4e90361e13fb3d74915eafc1f3a481400c798e0e/suds/bindings/binding.py#L182 - and work in the opposite direction there is.

0
source

All Articles