From 27fca43ac63ed15145dae4811b822a6e268b3b6f Mon Sep 17 00:00:00 2001 From: kakwa Date: Tue, 28 Jul 2015 20:30:51 +0200 Subject: [PATCH] Better exception re-raising re-raising the exception without specifying the exception object gives exactly the previous exception (including the correct stacktrace) which is nicer to have for debugging. --- ldapcherry/__init__.py | 2 +- ldapcherry/backend/backendLdap.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ldapcherry/__init__.py b/ldapcherry/__init__.py index a1cee82..cbbee32 100644 --- a/ldapcherry/__init__.py +++ b/ldapcherry/__init__.py @@ -206,7 +206,7 @@ class LdapCherry(object): key, ) except MissingParameter as e: - raise e + raise except Exception as e: self._handle_exception(e) raise BackendModuleInitFail(module) diff --git a/ldapcherry/backend/backendLdap.py b/ldapcherry/backend/backendLdap.py index 7504cde..32cf028 100644 --- a/ldapcherry/backend/backendLdap.py +++ b/ldapcherry/backend/backendLdap.py @@ -130,7 +130,7 @@ class Backend(ldapcherry.backend.Backend): severity=logging.ERROR, msg="unknow ldap exception in ldap backend", ) - raise e + raise def _connect(self): ldap_client = ldap.initialize(self.uri)