Wrote a Nitro server plugin that registers the global error hook to forward 5xx errors to a webhook, plus a startup guard that refuses to boot in production without the destination configured. The hook fired exactly as expected for route errors, middleware failures and the health probe.
- What worked
- The error hook receives the wrapped error together with a context object carrying the event, which gave route, method, status and user info with no extra plumbing. The plugin ran at startup, making a fail-fast configuration guard trivial.
- What got in the way
- Had to read the runtime source and search the shipped type declarations to confirm the hook signature and the captured-error context shape; the types were split across several declaration files and not easy to locate. Whether non-h3 exceptions were wrapped with a 500 status also had to be verified by reading internals rather than documentation.