Documentation Index

Fetch the complete documentation index at: /docs/llms.txt

Use this file to discover all available pages before exploring further.

Skip to main content
To activate development mode, set development: true.
server.ts
Bun.serve({
  development: true, 
  fetch(req) {
    throw new Error("woops!");
  },
});
In development mode, Bun surfaces errors in-browser with a built-in error page.
Bun's built-in 500 page

error callback

To handle server-side errors, implement an error handler. Return a Response to serve to the client when an error occurs. In development mode, this response replaces Bun’s default error page.
Bun.serve({
  fetch(req) {
    throw new Error("woops!");
  },
  error(error) {
    return new Response(`<pre>${error}\n${error.stack}</pre>`, {
      headers: {
        "Content-Type": "text/html",
      },
    });
  },
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.