Make totpcgi log errors

Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
This commit is contained in:
Patrick Uiterwijk 2019-05-23 22:23:01 +02:00
parent 639bbc3e0f
commit e898e9a320

View file

@ -190,4 +190,15 @@ def cgimain():
sys.stdout.write(success_string)
if __name__ == '__main__':
cgimain()
try:
cgimain()
except Exception:
logging.exception("Server error during processing")
output = 'ERR\nInternal server error\n'
sys.stdout.write('Status: 500 SERVER ERROR\n')
sys.stdout.write('Content-type: text/plain\n')
sys.stdout.write('Content-Length: %s\n' % len(output))
sys.stdout.write('\n')
sys.stdout.write(output)
sys.exit(0)