mirror of
https://github.com/hanzoai/dev-desktop.git
synced 2026-11-20 01:07:23 +00:00
19 lines
645 B
TypeScript
19 lines
645 B
TypeScript
import * as Cause from "effect/Cause";
|
|
import * as Effect from "effect/Effect";
|
|
import * as ErrorReporter from "effect/ErrorReporter";
|
|
|
|
// RpcServer reports typed failures too; log only defects.
|
|
const reporter: ErrorReporter.ErrorReporter = {
|
|
[ErrorReporter.TypeId]: ErrorReporter.TypeId,
|
|
report: ({ cause, fiber }) => {
|
|
for (const reason of cause.reasons) {
|
|
if (reason._tag !== "Die" || ErrorReporter.isIgnored(reason.defect)) continue;
|
|
Effect.runForkWith(fiber.context)(
|
|
Effect.logError("Unhandled defect", Cause.fromReasons([reason])),
|
|
);
|
|
}
|
|
},
|
|
};
|
|
|
|
export const layer = ErrorReporter.layer([reporter]);
|