summaryrefslogtreecommitdiff
path: root/suds
diff options
context:
space:
mode:
authorjortel <devnull@localhost>2008-07-08 16:03:46 +0000
committerjortel <devnull@localhost>2008-07-08 16:03:46 +0000
commit66b5f01dc075d6c6bb70be931cc5fe2ede5f3db1 (patch)
tree215ea03ef1a140da4a892b24bb3bc2c1992b9ab7 /suds
parentb581a931272d49d85e9fd630961ce44937cc53f5 (diff)
downloadsuds-66b5f01dc075d6c6bb70be931cc5fe2ede5f3db1.tar.gz
Update exceptions to be more /standard/ python by using Exception.__init__() to set Exception.message as suggested by Ticket #14; update bindings to raise WebFault passing (p)
Diffstat (limited to 'suds')
-rw-r--r--suds/__init__.py43
-rw-r--r--suds/bindings/binding.py2
2 files changed, 16 insertions, 29 deletions
diff --git a/suds/__init__.py b/suds/__init__.py
index 8cf442e..6cee2a8 100644
--- a/suds/__init__.py
+++ b/suds/__init__.py
@@ -30,41 +30,28 @@ socket.setdefaulttimeout(10)
class MethodNotFound(Exception):
def __init__(self, name):
- self.name = name
- def __str__(self):
- return unicode(self).encode('utf-8')
- def __unicode__(self):
- return 'service method: %s not-found' % unicode(self.name)
+ Exception.__init__(self, "Method not found: '%s'" % name)
class TypeNotFound(Exception):
def __init__(self, name):
- self.name = name
- def __str__(self):
- return unicode(self).encode('utf-8')
- def __unicode__(self):
- return 'WSDL/XSD type: %s not-found' % unicode(self.name)
+ Exception.__init__(self, "Type not found: '%s'" % name)
class BuildError(Exception):
- def __init__(self, type):
- self.type = type
- def __str__(self):
- return unicode(self).encode('utf-8')
- def __unicode__(self):
- return \
- """
- An error occured while building a instance of (%s). As a result
- the object you requested could not be constructed. It is recommended
- that you construct the type manually uisng a Suds object.
- Please notify the project mantainer of this error.
- """ % unicode(self.type)
+ msg = \
+ """
+ An error occured while building a instance of (%s). As a result
+ the object you requested could not be constructed. It is recommended
+ that you construct the type manually uisng a Suds object.
+ Please notify the project mantainer of this error.
+ """
+ def __init__(self, name):
+ Exception.__init__(self, BuildError.msg % name)
class WebFault(Exception):
- def __init__(self, type):
- self.type = type
- def __str__(self):
- return unicode(self).encode('utf-8')
- def __unicode__(self):
- return 'service endpoint raised fault %s\n' % unicode(self.type)
+ def __init__(self, fault):
+ if hasattr(fault, 'faultstring'):
+ Exception.__init__(self, "Server raised fault: '%s'" % fault.faultstring)
+ self.fault = fault
#
# Logging
diff --git a/suds/bindings/binding.py b/suds/bindings/binding.py
index 4e25655..377b465 100644
--- a/suds/bindings/binding.py
+++ b/suds/bindings/binding.py
@@ -136,7 +136,7 @@ class Binding:
unmarshaller = self.unmarshaller.basic
p = unmarshaller.process(fault)
if self.faults:
- raise WebFault(unicode(p))
+ raise WebFault(p)
else:
return p.detail