Commit 05c22c49 by Victor Shnayder

Prettier error display

* Log formatted traceback string instead of exc_info tuple itself
* display as a list
parent 32253510
import logging
import sys
import traceback
from collections import namedtuple
......@@ -14,21 +15,21 @@ def in_exception_handler():
def make_error_tracker():
'''Return an ErrorLog (named tuple), with fields (tracker, errors), where
the logger appends a tuple (message, exc_info=None)
to the errors on every call.
the logger appends a tuple (message, exception_str) to the errors on every
call. exception_str is in the format returned by traceback.format_exception.
error_list is a simple list. If the caller messes with it, info
error_list is a simple list. If the caller modifies it, info
will be lost.
'''
errors = []
def error_tracker(msg):
'''Log errors'''
exc_info = None
exc_str = ''
if in_exception_handler():
exc_info = sys.exc_info()
exc_str = ''.join(traceback.format_exception(*sys.exc_info()))
errors.append((msg, exc_info))
errors.append((msg, exc_str))
return ErrorLog(error_tracker, errors)
......
......@@ -51,7 +51,13 @@
% if course_errors is not UNDEFINED:
<h2>Course errors</h2>
<div id="course-errors">
${course_errors}
<ul>
% for (msg, err) in course_errors:
<li>${msg}
<ul><li><pre>${err}</pre></li></ul>
</li>
% endfor
</ul>
</div>
% endif
</section>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment