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
1 changed files with 6 additions and 1 deletions

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