[ldapparser] raise specific error if the configuration is wrong (closes #2498164) stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Mon, 01 Oct 2012 12:40:35 +0200
branchstable
changeset 8566 76bcfb3c483d
parent 8565 53c8cf9450b9
child 8567 1ac70b1bf00e
[ldapparser] raise specific error if the configuration is wrong (closes #2498164)
sobjects/ldapparser.py
--- a/sobjects/ldapparser.py	Mon Oct 08 17:50:12 2012 +0200
+++ b/sobjects/ldapparser.py	Mon Oct 01 12:40:35 2012 +0200
@@ -25,7 +25,7 @@
 from logilab.common.decorators import cached
 from logilab.common.shellutils import generate_password
 
-from cubicweb import Binary
+from cubicweb import Binary, ConfigurationError
 from cubicweb.server.utils import crypt_password
 from cubicweb.server.sources import datafeed
 
@@ -92,7 +92,12 @@
             tdict = {}
         for sattr, tattr in self.source.user_attrs.iteritems():
             if tattr not in self.non_attribute_keys:
-                tdict[tattr] = sdict[sattr]
+                try:
+                    tdict[tattr] = sdict[sattr]
+                except KeyError:
+                    raise ConfigurationError('source attribute %s is not present '
+                                             'in the source, please check the '
+                                             'user-attrs-map field' % sattr)
         return tdict
 
     def before_entity_copy(self, entity, sourceparams):