morss: make errors more readable over http

master
pictuga 2020-03-21 23:08:29 +01:00
parent 42c5d09ccb
commit 421acb439d
1 changed files with 4 additions and 3 deletions

View File

@ -18,6 +18,7 @@ from . import readabilite
import wsgiref.simple_server import wsgiref.simple_server
import wsgiref.handlers import wsgiref.handlers
import cgitb
try: try:
@ -598,10 +599,10 @@ def cgi_wrapper(environ, start_response):
except (KeyboardInterrupt, SystemExit): except (KeyboardInterrupt, SystemExit):
raise raise
except Exception as e: except Exception as e:
headers = {'status': '500 Oops', 'content-type': 'text/plain'} headers = {'status': '500 Oops', 'content-type': 'text/html'}
start_response(headers['status'], list(headers.items()), sys.exc_info()) start_response(headers['status'], list(headers.items()), sys.exc_info())
log('ERROR <%s>: %s' % (url, e.message), force=True) log('ERROR: %s' % repr(e), force=True)
return ['An error happened:\n%s' % e.message] return [cgitb.html(sys.exc_info())]
def cli_app(): def cli_app():