MCPcopy Index your code
hub / github.com/coder/coder / RenderStaticErrorPage

Function RenderStaticErrorPage

site/site.go:721–742  ·  view source on GitHub ↗

RenderStaticErrorPage renders the static error page. This is used by app requests to avoid dependence on the dashboard but maintain the ability to render a friendly error page on subdomains.

(rw http.ResponseWriter, r *http.Request, data ErrorPageData)

Source from the content-addressed store, hash-verified

719// requests to avoid dependence on the dashboard but maintain the ability to
720// render a friendly error page on subdomains.
721func RenderStaticErrorPage(rw http.ResponseWriter, r *http.Request, data ErrorPageData) {
722 type outerData struct {
723 Error ErrorPageData
724
725 ErrorDescriptionHTML htmltemplate.HTML
726 }
727
728 rw.Header().Set("Content-Type", "text/html; charset=utf-8")
729 rw.WriteHeader(data.Status)
730
731 err := errorTemplate.Execute(rw, outerData{
732 Error: data,
733 ErrorDescriptionHTML: htmltemplate.HTML(data.Description), //nolint:gosec // gosec thinks this is user-input, but it is from Coder deployment configuration.
734 })
735 if err != nil {
736 httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{
737 Message: "Failed to render error page: " + err.Error(),
738 Detail: fmt.Sprintf("Original error was: %d %s, %s", data.Status, data.Title, data.Description),
739 })
740 return
741 }
742}
743
744func applicationNameOrDefault(cfg codersdk.AppearanceConfig) string {
745 if cfg.ApplicationName != "" {

Callers 15

userOIDCMethod · 0.92
ReverseProxyMethod · 0.92
WriteMethod · 0.92
handleAPIKeySmugglingMethod · 0.92
parseHostnameMethod · 0.92
proxyWorkspaceAppMethod · 0.92
WriteWorkspaceApp404Function · 0.92
WriteWorkspaceApp500Function · 0.92
WriteWorkspaceAppOfflineFunction · 0.92
WriteWorkspaceOfflineFunction · 0.92
ShowAuthorizePageFunction · 0.92

Calls 7

WriteFunction · 0.92
SetMethod · 0.65
ExecuteMethod · 0.65
ContextMethod · 0.65
HeaderMethod · 0.45
WriteHeaderMethod · 0.45
ErrorMethod · 0.45

Tested by 2