def get_exception_info(exception):
    """
    Format exception information for display on the debug page using the
    structure described in the template API documentation.
    """
    context_lines = 10
    lineno = exception.lineno
    lines = list(enumerate(exception.source.strip().split('\n'), start=1))
    during = lines[lineno - 1][1]
    total = len(lines)
    top = max(0, lineno - context_lines - 1)
    bottom = min(total, lineno + context_lines)
    return {'name': exception.filename, 'message': exception.message,
        'source_lines': lines[top:bottom], 'line': lineno, 'before': '',
        'during': during, 'after': '', 'total': total, 'top': top, 'bottom':
        bottom}
