Fork Horse repository, listed by its owner. Publisher snapshot.

packages/error-reporter/src/index.ts

Snapshot at 34e3175

Containing directory

745 bytes · typescriptView raw
1import { WorkerEntrypoint } from "cloudflare:workers";
2import type { ErrorEventV1, ErrorReporterProps } from "@gadgets/error-reporting";
3import { formatErrorLog } from "./format.js";
4
5export class ErrorReporter extends WorkerEntrypoint<unknown, ErrorReporterProps> {
6  async report(event: ErrorEventV1): Promise<void> {
7    console.error(formatErrorLog(this.ctx.props, event));
8  }
9}
10
11// Keep ES Module worker format; this worker is used over RPC, not HTTP. An empty default export
12// deploys as a script with no registered event handlers and the API rejects it.
13export default {
14  async fetch(): Promise<Response> {
15    return new Response("Error Reporter worker is running.", {
16      headers: { "content-type": "text/plain" },
17    });
18  },
19};
20