GOWDK separates expected handler results from unexpected generated-lane failures.
Expected errors are user-owned handler results:
- Return
runtime/response.Responsevalues for normal not-found, forbidden, invalid request, conflict, validation, redirect, HTML, fragment, and JSON outcomes. - Return typed expected errors with
response.NotFound,response.Forbidden,response.ValidationFailed, orresponse.ServerErrorwhen a generated boundary should map the error to 404, 403, 422, or 500. - Return
response.NewHandlerError(status, message, cause)when a generated action or API handler should fail with a specific HTTP status. - Return ordinary Go errors only for failures where HTTP 500 is acceptable.
Generated action and API adapters use
response.HandlerStatus, defaulting to HTTP 500. - Return
ssr.RedirectTo("/path")orssr.Redirect("/path", status)from SSR load functions for safe local redirects. - Return typed expected errors from SSR load functions when the page should use
a non-500 generated boundary. Expected 404 responses use
404.htmlwhen it exists. Expected 500 responses use the route-localerrorpage, nearest layout-levelerrorpage, outer layout-levelerrorpages, or500.htmlwhen available. Expected 403 and 422 responses use safe fallback text until status-specific generated documents are defined.
Unexpected errors are generated-lane failures:
- Generated SSR, action, and API lanes recover panics before response headers are written.
- Panic values are not rendered.
- Generated request-shape failures use generic messages such as
invalid form,invalid csrf token, orvalidation failed. - Generated form decoding and validation do not echo submitted values.
Generated embedded apps load these optional HTML files from build output:
| File | Used for |
|---|---|
404.html |
Not-found responses from generated app serving. |
500.html |
Internal generated error responses when no route-local page applies. |
Example output:
dist/
index.html
404.html
500.html
errors/
dashboard.html
Route-local SSR error pages use error:
route "/dashboard"
guard auth.required
error "/errors/dashboard.html"
server {
}
Layout-level SSR error pages use error in .layout.gwdk files:
error "/errors/app-shell.html"
view {
<main>
<slot />
</main>
}
For HTTP 500 SSR load, render, and panic boundaries, generated apps select error pages in this order:
- Route-local
erroron the SSR page. - The nearest layout-level
errorpage in the route's layout stack. - Outer layout-level
errorpages, including parent layouts. - Global
500.html. http.Error.
Endpoint-local action and API error pages also use error:
act Submit POST "/signup" error "/errors/signup.html"
api Health GET "/api/health" error "/errors/api-health.html"
error paths are output-relative. They may start with /, must end in
.html, and must not contain .., query strings, fragments, or backslashes.
Missing error documents fall back to http.Error.
Generated error responses use Cache-Control: no-store.
This includes generated 404.html, 500.html, route-local error pages,
panic-boundary responses, invalid generated forms, invalid CSRF responses,
validation failures, guard failures, missing backend stubs, and SSR load
failures. Successful SSR pages use their declared page cache policy instead.
Supported boundary syntax:
- Page/route boundary:
erroron SSR pages. - Layout boundary:
erroron layout files, selected for SSR 500 boundaries. - Endpoint boundary:
erroronactandapi. - Global fallback pages:
404.htmland500.html.
Not supported today:
- Component-level error boundary syntax.
- Fragment-specific error boundary syntax.
- Templated in-layout error-region syntax with typed error values.
- Generated response-transform hooks.
- Rendering panic values, submitted form values, secrets, or stack traces.
Generated panic boundaries render safe fixed messages or generated HTML error documents. They intentionally do not render panic values.
Generated action, API, fragment, contract, SSR load, and addon 5xx responses
hide ordinary returned error details. Apps can expose an intentional
client-facing message by returning response.HandlerError with an explicit
Message; 4xx handler errors keep their application message contract.
Runtime panic logs and compiler diagnostics apply conservative redaction before writing to logs, terminal output, JSON diagnostics, or LSP diagnostics. The redaction policy masks common credential surfaces:
- DSN passwords such as
postgres://user:password@host. - Bearer and Basic authorization header values.
password,passwd,pwd,secret,token,_gowdk_csrf,csrf_token,cookie,set-cookie,auth_token,session,session_id,jwt,api_key,access_key,access_token,refresh_token,id_token,client_secret, andprivate_keyvalues when they appear asname=valueorname: value.
Limitations: app-owned logging is outside GOWDK's control, and explicit
client-facing HandlerError.Message values are trusted as app-owned text. Do
not put secrets, credentials, submitted sensitive values, SQL details, or
internal service details in messages intended for clients.