{% load i18n %}
{% load sentry_helpers %}

<div class="module">
    <div class="page-header">
        {% block comment %}
            <a href="javascript:void(0)" data-container="#raw_stacktrace" data-title="Stacktrace" class="popup btn small pull-right">{% trans "Raw" %}</a>
        {% endblock %}
        {% if system_frames %}
            <form class="pull-right" style="margin:8px 20px 0 0; white-space: nowrap">
                <label class="checkbox"><input type="checkbox" id="show_hidden_frames"> Show {{ system_frames }} hidden frames</label>
            </form>
        {% endif %}
        <h2>
            {% trans "Exception" %}
            <small>{% if newest_first %}
                ({% trans "most recent call first" %})
            {% else %}
                ({% trans "most recent call last" %})
            {% endif %}</small>
        </h2>
    </div>
    <div class="module-content">
        {% for exception in exceptions %}
            <div class="traceback{% if not exception.is_root %} subtraceback{% endif %}">
                {% if not exception.is_root %}
                    <h3>Caused by <span title="{{ exception.fullname }}">{{ exception.exception_type }}</span></h3>
                {% else %}
                    <h3><span title="{{ exception.fullname }}">{{ exception.exception_type }}</span>{% if not newest_first %} <small>Root Cause</small>{% endif %}</h3>
                {% endif %}
                {% if exception.exception_value %}
                    <p>{{ exception.exception_value }}</p>
                {% endif %}
                {% with exception.stacktrace.frames as frames %}
                    {% with stack_id=exception.stack_id first_frame_omitted=exception.stacktrace.first_frame_omitted last_frame_omitted=exception.stacktrace.last_frame_omitted %}
                        {% include "sentry/partial/interfaces/stacktrace_inner.html" %}
                    {% endwith %}
                {% endwith %}
            </div>
        {% endfor %}
    </div>
</div>

<div id="raw_stacktrace" style="display: none;">
    <pre>{{ stacktrace }}</pre>
</div>

{% if system_frames %}
    <script type="text/javascript">
    $('#show_hidden_frames').change(function(e){
        var $el = $(e.target);
        if ($el.is(':checked')) {
            $('.traceback li.system-frame').show();
        } else {
            $('.traceback li.system-frame').hide();
        }
    }).change();
    </script>
{% endif %}
