1
0
forked from moepman/bk-dss

Improve error handling.

Some LDAPErrors might not contain a info or desc value, only add them
tothe message if they exist.
This commit is contained in:
Markus 2016-04-16 21:15:58 +02:00
parent 46e560cef9
commit 9669790224

View File

@ -105,7 +105,12 @@ def create():
except ldap.LDAPError as e: except ldap.LDAPError as e:
l.unbind_s() 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: else:
l.unbind_s() l.unbind_s()
return render_template('success.html', message="User successfully created.", nav=buildNav()) return render_template('success.html', message="User successfully created.", nav=buildNav())