Documentation
Docs
Introduction
Getting Started
Tutorial: build an app
Core Concepts
Routing
Server-Side Rendering
Mimir, state management
Pages & Layouts
API Routes
Styling & Theming
Building & Deploying
API Reference
Guides
Recipes
FAQ (use cases)
errorHandler()
Turn an uncaught error anywhere downstream into a clean 500, with a server-side log and no leaked stack.
Use case
An unhandled throw in a middleware or handler should never crash the process or leak a stack trace to the
client. errorHandler wraps the chain below it: on an error it logs the method, path, and error, then sends
a tidy 500, in production without revealing the internal detail.
How it works
Registered first, it wraps everything after it. If a downstream middleware or handler throws, it catches the
error, logs it server-side (method + path + error), and replies 500. With production: true (the default)
the body is a generic { error: "Internal Server Error" }; with production: false the body includes the
real error string, useful in development.
Configuration
| Option | Default | Notes |
|---|---|---|
production | true | When true, the 500 body hides the error detail; false includes it (dev only). |
Example
Notes
Register
errorHandlerfirst so it wraps the whole chain. rune also catches handler throws and returns500on its own;errorHandleradds the logging plus the production/dev shaping, and crucially covers the middleware chain, not just route handlers.
Next: httpsRedirect.