Exceptions

Michael Ströder michael at stroeder.com
Sat Oct 28 23:48:30 CEST 2006


Roland,

Roland Hedberg wrote:
> 
> If you encounter a problem the raises the exception, for instance
> TYPE_OR_VALUE_EXISTS, and then prints the exception info, it will come
> out looking something like this:
> 
> {'info': 'street: value #0 provided more than once', 'desc': 'Type or
> value exists'}
> 
> Which looks like when you print a dictionary.

It is a dictionary.

> The obvious:
> 
> try:
> 	....
> except ldap.TYPE_OR_VALUE_EXISTS, e:
> 	print e.info
> 
> doesn't work

Be warned: It's ugly!

e.args[0]['desc']
e.args[0]['info']

I really have no clue why David implemented it in this way. Guess it has
something to do with focusing on C programming. ;-)

Guess it's time for another wrapper class around exceptions raised by
_ldap...

Ciao, Michael.



More information about the python-ldap mailing list