The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Cause from "effect/Cause"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as ErrorReporter from "effect/ErrorReporter"; |
| 4 | |
| 5 | // RpcServer reports typed failures too; log only defects. |
| 6 | const reporter: ErrorReporter.ErrorReporter = { |
| 7 | [ErrorReporter.TypeId]: ErrorReporter.TypeId, |
| 8 | report: ({ cause, fiber }) => { |
| 9 | for (const reason of cause.reasons) { |
| 10 | if (reason._tag !== "Die" || ErrorReporter.isIgnored(reason.defect)) continue; |
| 11 | Effect.runForkWith(fiber.context)( |
| 12 | Effect.logError("Unhandled defect", Cause.fromReasons([reason])), |
| 13 | ); |
| 14 | } |
| 15 | }, |
| 16 | }; |
| 17 | |
| 18 | export const layer = ErrorReporter.layer([reporter]); |