-
Notifications
You must be signed in to change notification settings - Fork 6
/
debug_error_page.tpl.go
executable file
·65 lines (47 loc) · 1.26 KB
/
debug_error_page.tpl.go
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
54
55
56
57
58
59
60
61
62
63
64
65
//** This file was code generated by got. DO NOT EDIT. ***
package page
import (
"bytes"
"context"
"fmt"
"html"
"strings"
)
// The DebugErrorPageTmpl writes a debug error page to the html output so that it will display the error in the
// browser, possibly as a popup. Do not use this on the release server, as it may expose details of your application
// that you do not want exposed.
func DebugErrorPageTmpl(ctx context.Context, partialHtml string, err *Error, buf *bytes.Buffer) {
buf.WriteString(`<h1 id="err-title">Error</h1>
`)
items := strings.Split(err.Error(), "\n")
errTitle := items[0]
var errDesc string
if len(items) > 1 {
errDesc = strings.Join(items[1:], "<br />")
}
buf.WriteString(`<h2>`)
buf.WriteString(errTitle)
buf.WriteString(`</h2>
`)
if errDesc != "" {
buf.WriteString(`<p>`)
buf.WriteString(errDesc)
buf.WriteString(`</p>`)
}
buf.WriteString(`<h3>Call Path</h3>
<p>
`)
for _, stack := range err.Stack {
buf.WriteString(` `)
buf.WriteString(fmt.Sprintf("%s line %d in %s", stack.File, stack.Line, stack.Func))
buf.WriteString(` <br />
`)
}
buf.WriteString(`</p>
<h3>Generated Html</h3>
`)
buf.WriteString(strings.Replace(html.EscapeString(partialHtml), "\n", "<br>\n", -1))
buf.WriteString(`
`)
return
}