def render_error_debug(request, exc, content_type): '''Render the traceback into the content type in *response*.''' response = request.response is_html = content_type == 'text/html' error = Html('div', cn='section traceback error') if is_html else [] trace = format_traceback(exc) for trace in format_traceback(exc): counter = 0 for line in trace.split('\n'): if line.startswith(' '): counter += 1 line = line[2:] if line: if is_html: line = Html('p', escape(line)) if counter: line.css({'margin-left': '%spx' % (20*counter)}) error.append(line) return error
def render_error_debug(request, exception, is_html): '''Render the ``exception`` traceback ''' error = Html('div', cn='well well-lg') if is_html else [] for trace in format_traceback(exception): counter = 0 for line in trace.split('\n'): if line.startswith(' '): counter += 1 line = line[2:] if line: if is_html: line = Html('p', escape(line), cn='text-danger') if counter: line.css({'margin-left': '%spx' % (20*counter)}) error.append(line) if is_html: error = Html('div', Html('h1', request.response.status), error) return error
def render_error_debug(request, exception, is_html): '''Render the ``exception`` traceback ''' error = Html('div', cn='well well-lg') if is_html else [] for trace in format_traceback(exception): counter = 0 for line in trace.split('\n'): if line.startswith(' '): counter += 1 line = line[2:] if line: if is_html: line = Html('p', escape(line), cn='text-danger') if counter: line.css({'margin-left': '%spx' % (20 * counter)}) error.append(line) if is_html: error = Html('div', Html('h1', request.response.status), error) return error
def __init__(self, exc): self.exc = exc self.trace = format_traceback(exc)