+

Fix/improve error reporting

Benjamin Renard [2018-02-13 14:30:38]
Fix/improve error reporting
Filename
LdapServer.py
diff --git a/LdapServer.py b/LdapServer.py
index 93102ae..3ef0752 100644
--- a/LdapServer.py
+++ b/LdapServer.py
@@ -23,7 +23,7 @@ class LdapServer(object):

 	def _error(self,error,level=logging.WARNING):
 		if self.raiseOnError:
-			raise LdapServerException('LdapServer - Error connecting and binding to LDAP server : %s' % error)
+			raise LdapServerException(error)
 		else:
 			logging.log(level,error)

@@ -67,7 +67,7 @@ class LdapServer(object):
 			self.con.add_s(dn,ldif)
 			return True
 		except ldap.LDAPError, e:
-			self._error("LdapServer - Error adding %s : %s" % (dn,e))
+			self._error("LdapServer - Error adding %s : %s" % (dn,e), logging.error)

 		return False

@@ -79,7 +79,7 @@ class LdapServer(object):
 			self.con.modify_s(dn,ldif)
 			return True
 		except ldap.LDAPError, e:
-			self._error("LdapServer - Error updating %s : %s\nOld : %s\nNew : %s" % (dn, e, old, new))
+			self._error("LdapServer - Error updating %s : %s\nOld : %s\nNew : %s" % (dn, e, old, new), logging.error)
 		return False

 	def rename_object(self,dn,new_rdn):
@@ -88,7 +88,7 @@ class LdapServer(object):
 			self.con.rename_s(dn,new_rdn)
 			return True
 		except ldap.LDAPError, e:
-			self._error("LdapServer - Error renaming %s in %s : %s" % (dn,new_rdn,e))
+			self._error("LdapServer - Error renaming %s in %s : %s" % (dn,new_rdn,e), logging.error)

 		return False

@@ -98,7 +98,7 @@ class LdapServer(object):
 			self.con.delete_s(dn)
 			return True
 		except ldap.LDAPError, e:
-			self._error("LdapServer - Error deleting %s : %s" % (dn,e))
+			self._error("LdapServer - Error deleting %s : %s" % (dn,e), logging.error)

 		return False
ViewGit