Browse Source

Show template exceptions.

develop
Sam Black 4 years ago
parent
commit
82587cefbb
Signed by: samwwwblack GPG Key ID: 0FF0223994EA47D8
  1. 35
      cupola/templates/events/macros.html

35
cupola/templates/events/macros.html

@ -1,3 +1,4 @@
{# Exception handler #}
{% macro show_exception(event) %}
{% if event.exceptions %}
<h3>{{ gettext("Exception") }}</h3>
@ -15,7 +16,7 @@
{{ show_stacktrace(event.stacktrace) }}
{% elif event.template %}
<h3>{{ gettext("Template fault") }}</h3>
{{ event.template }}
{{ show_template(event.template) }}
{% elif event.logevent %}
<h3>{{ gettext("Log event") }}</h3>
{{ event.logevent["formatted"] or event.logevent["message"] }}
@ -24,12 +25,11 @@
{% endif %}
{% endmacro %}
{% macro show_stacktrace(stacktrace) %}
{% if stacktrace is not none %}
{% for frame in stacktrace.frames | sort(attribute="order") %}
{{frame.filename}}:{{ frame.lineno }} &mdash; {{ frame.module + ":" if frame.module }}{{ frame.function }}
{% if frame.post_context is not none and frame.post_context != "Unknown" %}
<pre class="prettyprint linenums:{{ frame.lineno - 5 }}">
{% macro _code_context(frame) %}
{% set location = frame.module if frame.module else frame.abs_path %}
{{frame.filename}}:{{ frame.lineno }} &mdash; {{ location }}:{{ frame.function }}
{% if frame.post_context is not none and frame.post_context != "Unknown" %}
<pre class="prettyprint linenums:{{ frame.lineno - 5 }}">
{% if frame.pre_context is not none %}
{{ frame.pre_context | join("\n") }}
{% endif %}
@ -37,11 +37,17 @@
{% if frame.post_context is not none %}
{{ frame.post_context | join("\n") }}
{% endif %}
</pre>
<br/>
{% else %}
<p>{{ gettext("No exception context available") }}</p>
{% endif %}
</pre>
<br/>
{% else %}
<p>{{ gettext("No exception context available") }}</p>
{% endif %}
{% endmacro %}
{% macro show_stacktrace(stacktrace) %}
{% if stacktrace is not none %}
{% for frame in stacktrace.frames | sort(attribute="order") %}
{{ _code_context(frame) }}
{% endfor %}
{% else %}
<div>
@ -50,6 +56,11 @@
{% endif %}
{% endmacro %}
{% macro show_template(template) %}
{{ _code_context(template) }}
{% endmacro %}
{# Side bar information #}
{% macro show_tags(event) -%}

Loading…
Cancel
Save