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