[python3-ldap] Feature requests: clearer errors

python3ldap python3ldap at gmail.com
Wed Apr 16 21:09:47 CEST 2014


Hello Michael, thanks for your response,
in python3-ldap when you send an operation you get a boolean as return
value that indicates if the operation is successful or not. You then
can get the result details in connection.result. Do you mean that
everytime that an operation is not successful I should raise an
exception?

I like the idea to let the socket exception flow up to the calling
application, except than for the Restartable strategy, that
autoreconnect to the server pool. Another solution could be to have an
exception with mutiple inheritance, to let the calling application
decide if to catch all LDAPExceptions in a single except clause or
more fine-grained exceptions and use LDAPException as a catchall. I
haven't seen many project with multiple inheritance for exceptions, so
I'm quite cautious with this solution, maybe there are some drawbacks
that I don't understand.

Bye,
Giovanni


2014-04-16 11:29 GMT+02:00 Michael Ströder <michael at stroeder.com>:
> On Wed, 16 Apr 2014 10:40:25 +0200 python3ldap <python3ldap at gmail.com> wrote
>> My problem is that I'm not sure if is better to let the
>> socket errors (and other standard exceptions) flow up or trap them and
>> re-raise a custom exception in a custom hierarchy. Do you have any
>> suggestion? What other people in this list think about this?
>
> At least you should map any LDAP result code to a separate exception attaching
> more data returned by the server with the result like response controls.
> Otherwise fine-grained error handling is impossible.
>
> For socket errors I'd recommend to not catch them within your module.
> Just let the calling application deal with them.
>
> Ciao, Michael.
>
>


More information about the python3-ldap mailing list