1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| {% import ( "strings"
"{{{ .Package }}}/app" "{{{ .Package }}}/app/controller/cutil"{{{ if .HasAccount }}} "{{{ .Package }}}/app/lib/user"{{{ end }}} "{{{ .Package }}}/app/util" "{{{ .Package }}}/views/layout" ) %}
{%- func errorStack(ed *util.ErrorDetail) -%} <div class="overflow full-width"> <table> <tbody> {%- for _, f := range util.TraceDetail(ed.StackTrace) -%} <tr> <td> {%- if strings.Contains(f.Key, util.AppKey) -%} <div class="error-key error-owned">{%s f.Key %}</div> {%- else -%} <div class="error-key">{%s f.Key %}</div> {%- endif -%} <div class="error-location">{%s f.Loc %}</div> </td> </tr> {%- endfor -%} </tbody> </table> </div> {%- endfunc -%}
{% code type Error struct { layout.Basic Err *util.ErrorDetail } %}
{% func (p *Error) Body(as *app.State, ps *cutil.PageState) %} {%= Detail(p.Err, as, ps) %} {% endfunc %}
{% func Detail(ed *util.ErrorDetail, as *app.State, ps *cutil.PageState) %} <div class="card"> <h3>{%s ed.Message %}</h3> <em>Internal Server Error</em>{{{ if .HasAccount }}} {%- if user.IsAdmin(ps.Accounts) -%}{{{ end }}} {%= errorStack(ed) %} {% code cause := ed.Cause %} {%- for cause != nil -%} <h3>Caused by</h3> <div>{%s cause.Message %}</div>{%= errorStack(cause) %}{% code cause = cause.Cause %} {%- endfor -%}{{{ if .HasAccount }}} {%- endif -%}{{{ end }}} </div> {% endfunc %}
|