MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / ErrorPage

Function ErrorPage

server/common/common.go:47–77  ·  view source on GitHub ↗

ErrorPage is used to return error page HTML. It also returns standard HTTP status code. @param l: if true, log error

(c *gin.Context, err error, code int, l ...bool)

Source from the content-addressed store, hash-verified

45// It also returns standard HTTP status code.
46// @param l: if true, log error
47func ErrorPage(c *gin.Context, err error, code int, l ...bool) {
48
49 if len(l) > 0 && l[0] {
50 if flags.Debug || flags.Dev {
51 log.Errorf("%+v", err)
52 } else {
53 log.Errorf("%v", err)
54 }
55 }
56
57 codes := fmt.Sprintf("%d %s", code, http.StatusText(code))
58
59 html := fmt.Sprintf(`<!DOCTYPE html>
60<html lang="en">
61 <head>
62 <meta charset="utf-8" />
63 <meta name="viewport" content="width=device-width, initial-scale=1" />
64 <meta name="color-scheme" content="dark light" />
65 <meta name="robots" content="noindex" />
66 <title>%s</title>
67 </head>
68 <body>
69 <h1>%s</h1>
70 <hr>
71 <p>%s</p>
72 </body>
73</html>`,
74 codes, codes, html.EscapeString(hidePrivacy(err.Error())))
75 c.Data(code, "text/html; charset=utf-8", []byte(html))
76 c.Abort()
77}
78
79func ErrorWithDataResp(c *gin.Context, err error, code int, data interface{}, l ...bool) {
80 if len(l) > 0 && l[0] {

Callers 11

DownFunction · 0.92
ArchiveDownFunction · 0.92
ArchiveProxyFunction · 0.92
ArchiveInternalExtractFunction · 0.92
SharingDownFunction · 0.92
SharingArchiveExtractFunction · 0.92
dealErrorPageFunction · 0.92
DownFunction · 0.92
ProxyFunction · 0.92
redirectFunction · 0.92
proxyFunction · 0.92

Calls 3

hidePrivacyFunction · 0.85
EscapeStringMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected