Skip to content

Errors

The server returns 404 for a missing route and normally 500 for failed parsing or interpretation. Supported runtime exceptions can supply another HTTP error status.

Place error.nubo at the served directory’s root. When serving a single file, the server looks beside that file.

app/
index.nubo
error.nubo

The server attempts the custom page before its built-in development or production response. It supplies fresh request/response bindings and an @server/error object:

FieldTypeMeaning
statusintHTTP error status.
messagestringDetailed message in development; public status text in production.
app/error.nubo
import request from "@server/request"
import response from "@server/response"
import problem from "@server/error"
response.status(problem.status)
response.header("Content-Type", "text/html; charset=utf-8")
response.write(<main>
<h1>Error {problem.status}</h1>
<p>{problem.message}</p>
<small>{request.path}</small>
</main>)

To make this page return JSON instead:

app/error.nubo
import response from "@server/response"
import problem from "@server/error"
response.status(problem.status)
response.json(dict[string, any] {
status: problem.status,
message: problem.message
})

@server/error is request-specific server information. It is not the global Error struct created by language-level catch blocks.

The server logs the original failure and the error-page failure together. A fallback page that produces no body is treated as failed, except for responses where an empty body is expected, such as HEAD, 204, 304, or a redirect.

A failed custom page’s buffered output is discarded before the built-in fallback is written. This keeps partial page output from hiding the diagnostic response.

Terminal window
nubo serve app --dev --loglevel debug

If no usable custom page is available, development mode returns detailed exception information. A request whose Accept header includes application/json gets JSON; otherwise the fallback is an HTML diagnostic page. If both the route and custom page fail, diagnostics include both failures.

Without --dev, the built-in fallback uses a generic status message rather than exposing internals. JSON-preferring clients receive a status/message object; other clients receive plain text.

Server failures are logged through Zap when an error logger is enabled, with a standard Go logger fallback when needed. --dev controls development behavior; use --loglevel debug or another explicit level to enable structured interpreter/server logs. The default prod logging level disables the Zap logger.

For failures you want to turn into an application response yourself, use catch in the route and write the intended status and body.