WriteWorkspaceApp500 writes a HTML 500 error page for a workspace app. If appReq is not nil, it's fields will be added to the logged error message.
(log slog.Logger, accessURL *url.URL, rw http.ResponseWriter, r *http.Request, appReq *Request, err error, msg string)
| 47 | // WriteWorkspaceApp500 writes a HTML 500 error page for a workspace app. If |
| 48 | // appReq is not nil, it's fields will be added to the logged error message. |
| 49 | func WriteWorkspaceApp500(log slog.Logger, accessURL *url.URL, rw http.ResponseWriter, r *http.Request, appReq *Request, err error, msg string) { |
| 50 | ctx := r.Context() |
| 51 | if appReq != nil { |
| 52 | slog.Helper() |
| 53 | ctx = slog.With(ctx, |
| 54 | slog.F("username_or_id", appReq.UsernameOrID), |
| 55 | slog.F("workspace_and_agent", appReq.WorkspaceAndAgent), |
| 56 | slog.F("workspace_name_or_id", appReq.WorkspaceNameOrID), |
| 57 | slog.F("agent_name_or_id", appReq.AgentNameOrID), |
| 58 | slog.F("app_name_or_port", appReq.AppSlugOrPort), |
| 59 | slog.F("hostname_prefix", appReq.Prefix), |
| 60 | ) |
| 61 | } |
| 62 | log.Warn(ctx, |
| 63 | "workspace app auth server error: "+msg, |
| 64 | slog.Error(err), |
| 65 | ) |
| 66 | |
| 67 | site.RenderStaticErrorPage(rw, r, site.ErrorPageData{ |
| 68 | Status: http.StatusInternalServerError, |
| 69 | Title: "Internal Server Error", |
| 70 | Description: "An internal server error occurred.", |
| 71 | Actions: []site.Action{ |
| 72 | { |
| 73 | URL: accessURL.String(), |
| 74 | Text: "Back to site", |
| 75 | }, |
| 76 | }, |
| 77 | }) |
| 78 | } |
| 79 | |
| 80 | // WriteWorkspaceAppOffline writes a HTML 404 error page for a workspace app. If |
| 81 | // appReq is not nil, it will be used to log the request details at debug level. |
no test coverage detected