Files

18 lines
631 B
TypeScript

import { dbConfigured } from "../../db/index.ts";
import { run } from "../../db/run.ts";
import { newBudget, report } from "./sink.ts";
/** This process's write budget for the sink (`sink.ts`, "bounded three ways"). */
const budget = newBudget();
/**
* Report a server error from the app: the sink, bound to the pool.
*
* `route` is a route PATTERN (a file path or a literal), never a requested
* address. Does nothing without a database, and never throws.
*/
export async function reportServerError(route: string, error: unknown): Promise<void> {
if (!dbConfigured()) return;
await report(run, route, error, budget);
}