mirror of
https://github.com/bitbaum/heidi.git
synced 2026-12-05 16:17:13 +01:00
Claude-Session: https://claude.ai/code/session_019MDtmvb6xi489TfZMg7n9T Co-authored-by: Claude <noreply@anthropic.com>
20 lines
901 B
TypeScript
20 lines
901 B
TypeScript
import type { Instrumentation } from "next";
|
|
|
|
/**
|
|
* Next's hook for an error that reached the server's boundary: thrown while
|
|
* rendering a page, or out of a route handler, and not caught by anybody.
|
|
*
|
|
* It hands the error to the one sink (`lib/domain/errors/sink.ts`) with the
|
|
* route's FILE path (`context.routePath`, e.g. `/[locale]/practice`), not
|
|
* the address that was requested: the address can carry what a person typed.
|
|
* The request's headers are not read at all.
|
|
*
|
|
* Imported inside the function: this file is also evaluated in runtimes
|
|
* that have no database driver, and at build time.
|
|
*/
|
|
export const onRequestError: Instrumentation.onRequestError = async (error, _request, context) => {
|
|
if (process.env.NEXT_RUNTIME !== "nodejs") return;
|
|
const { reportServerError } = await import("./lib/domain/errors/report.ts");
|
|
await reportServerError(context.routePath, error);
|
|
};
|