From 966979022409eb8960c744031b8542169465a632 Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Sat, 16 Apr 2016 21:15:58 +0200 Subject: [PATCH] Improve error handling. Some LDAPErrors might not contain a info or desc value, only add them tothe message if they exist. --- index.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.py b/index.py index fbe0e05..227df47 100755 --- a/index.py +++ b/index.py @@ -105,7 +105,12 @@ def create(): except ldap.LDAPError as e: l.unbind_s() - return render_template('error.html', message=e.message['desc'] + ": " + e.message['info'], nav=buildNav()) + message = "LDAP Error" + if 'desc' in e.message: + message = message + " " + e.message['desc'] + if 'info' in e.message: + message = message + ": " + e.message['info'] + return render_template('error.html', message=message, nav=buildNav()) else: l.unbind_s() return render_template('success.html', message="User successfully created.", nav=buildNav())