kartagis / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

SoapFault has poor str() representation. #27

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The SoapFault exception class takes the faultcode and faultstring, but doesn't 
call the superconstructor with those values.

That means that if the exception is raised, it doesn't print out the faultcode 
or faultstring in the representation of it,
since RuntimeError.__init__ wasn't called.

A better implementation would be:

class SoapFault(RuntimeError):

    def __init__(self, faultcode, faultstring):
        self.faultcode = faultcode
        self.faultstring = faultstring
        RuntimeError.__init__(self, faultcode, faultstring)

    def __str__(self):
        return '%s: %s' % (self.faultcode, self.faultstring)

Original issue reported on code.google.com by allan.cr...@yougov.com on 6 May 2011 at 3:20

GoogleCodeExporter commented 8 years ago
Did you test this against unicode soap exceptions?
I did have problems with non ASCII characters.
Maybe overriding __unicode__ would be a better approach.

Original comment by reingart@gmail.com on 10 May 2011 at 9:37

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I didn't test it against unicode exceptions.

Perhaps it would just be easier to not override __str__. As long as the 
arguments are passed down to the constructor of the superclass, that should be 
good enough for me.

Original comment by allan.cr...@yougov.com on 11 May 2011 at 3:51

GoogleCodeExporter commented 8 years ago
fixed in change 5b5cf9ebc316

Original comment by reingart@gmail.com on 23 Nov 2011 at 6:15