[Fedora-suds-list] Proposal for a re-work of exceptions in Suds

Daniel Rodriguez danjrod at gmail.com
Tue Apr 27 22:23:20 UTC 2010


Hi Jeff,

I was reworking the error managing of the library I have built on top of
Suds and I think that the Exceptions raised by Suds could be reworked to
allow a finer "catching" granularity, without impacting the current system.

I assume that Suds does only raise exceptions defined in suds/__init__.py
and then:

   - All defined exceptions but WebFault belong to the pre-network stage.
   - WebFault belongs to the the post-network stage (suds can only detect a
   "webfault" once it has seen the answer from the server

It is obvious, in my opinion, that some people would like to treat those 2
groups of exceptions differently and maybe have just to "excepts" handling
the potential cases. But this is difficult, given that all exceptions are
derived from "Exception".

An initial proposal would then be:

   - Have a "SudsError" (derived from Exception) that will act as a base
   class for all Suds exceptions.
   - Derive (obviously) all exceptions from "SudsError"

This would allow implementing the following:

try:
  mysudsclient.callmethod(param)
except suds.WebFault as wf:
  doSomethingWithTheWebFault(wf)
except suds.SudsError as se:
  doSomethingWithSudsError(se)
except Exception as ex:
  doSomethingWithRegularPythonException(ex)

Even standard SudsError exceptions can be separated from standard Python
Exceptions and handled separately.

This is, again in my opinion, straightforward and poses no change to the
existing interface, while delivering (as stated above) a greater  control
over exception handling in suds.

I can implement a patch if you think that this approach is something
interesting for suds.

Best regards

Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/suds/attachments/20100428/fd4703e5/attachment.html 


More information about the suds mailing list