1
0
mirror of https://github.com/moepman/bk-dss synced 2024-12-22 06:54:26 +01:00

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:
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())