Open History to see the last commit
1import * as Cause from "effect/Cause";
2import * as Effect from "effect/Effect";
3import * as ErrorReporter from "effect/ErrorReporter";
4
5/**
6 * RpcServer reports every failed handler exit; typed failures are expected responses, so only
7 * dies are logged.
8 */
9const reporter: ErrorReporter.ErrorReporter = {
10 [ErrorReporter.TypeId]: ErrorReporter.TypeId,
11 report: ({ cause, fiber }) => {
12 for (const reason of cause.reasons) {
13 if (reason._tag !== "Die" || ErrorReporter.isIgnored(reason.defect)) continue;
14 Effect.runForkWith(fiber.context)(
15 Effect.logError("Unhandled defect", Cause.fromReasons([reason])),
16 );
17 }
18 },
19};
20
21export const layer = ErrorReporter.layer([reporter]);